Data Structures and Performance Quiz Answers – Networking Funda

Data Structures and Performance Week 01 Quiz Answers

Q1. Which of the following will you learn in this course? Select all that apply.

  • The difference between an abstract data type (ADT) and its implementation.
  • How to analyze the performance of code, both using Big-O notation and through benchmarking experiments.
  • How to implement the LinkedList data structure.
  • How to test your code using the JUnit framework.
  • How to implement data structures using the Python programming language.

Q2. True or False: We recommend you take a linear path through this course, watching each resource in the order in which it occurs.

  • True
  • False

Q3. True or False: The Document class is an abstract class.

  • True
  • False

Q4. Which of the following is a correct statement about the class hierarchy in the starter code:1 point

  • Document is a subclass of BasicDocument
  • Both BasicDocument and EfficientDocument are subclasses of Document
  • BasicDocument is a subclass of Document and EfficientDocument is a subclass of BasicDocument.

Q5. Which method in the Document class is called when the user of the MainApp (the text application) clicks the Flesch Index button?

  • getFleschScore()
  • getText()
  • getNumWords()
  • getTokens()

Q6. Have you worked with Strings in Java before?

  • Yes, extensively
  • A little bit
  • No, not at all

Data Structures and Performance Week 02 Quiz Answers

Module and Programming Assignment Quiz

Q1. What will be printed by the following code? Of course, you can run this code and get the question right, but we want you to answer this question (and all of these questions) without running the code.

String s1 = new String("String 1");
String s2 = "String 1";
if (s1 == s2) {    
System.out.println("Equal");
else {    
System.out.println("Not equal");
}
  • Not equal
  • Equal

Q2. Which of the following lines of code correctly assign a String containing the text “My String” to the variable ‘text’?

(Select all correct options.)

String s1 = "My String";
String text = s1;
 String text = "My ";
String s2 = "String";
text = text + s2 
  • correct answer
 ;String text = new String("My ");
text + new String("String"); 
  • correct answer
 text.concat("String");
String text = "My "; 

Q3. What best describes the functionality of the following method?

public int mystery(String s){    
char[] letters = s.toCharArray();    
int x = 0;    
for (int i = 0; 
i < letters.length; i++) {        
if (letters[i] == ' ') {           
letters[i] = '_';           
x++;        
}    
}    
return x;
}
  • It counts the number of spaces in a given string, and returns the count. It does not change the original String.
  • It counts the number of spaces in a given String and returns the count. It also replaces all spaces in the given String with underscore characters (‘_’).
  • It counts the number of total characters in the String and returns the count. It also replaces all spaces in the given String with underscore characters (‘_’).

Q4. Assume you have a String variable s that stores the text 1"%one%%two%%%three%%%%"

Which of the following calls to s.split will return the String array: 1["%", "%%", "%%%", "%%%%"]

(Select all correct options.)

s.split("%+");
 s.split("[a-z]+"); 
 s.split("one|two|three"); 
  • correct answer
 s.split("[one,two,three]"); 

Q5. Assume that you have a Document object stored in the variable d, whose whole text string is

"one (1), two (2), three (3)"

Which of the following calls to getTokens will return the list of Strings given here:

["one", "(1)", "two", "(2)", "three", "(3)"]

Pay attention to the spaces in the original string, and also notice the commas are not preserved in the strings in the list.

(Select all correct options.)

d.getTokens("[^, ]+");
  • correct answer

Notice there is a space after the comma in the character class.

d.getTokens("[^,]+");

Notice there is NO space after the comma in the character class.

d.getTokens("[a-z()0-9]+");

Hint: The ( ) will be treated as literal tokens inside the character set.

d.getTokens("[a-z]+|[()0-9]+");

. Hint: The ( ) will be treated as literal tokens inside the character set.

Q6. Does a higher or lower Flesch Index Score indicate simpler text?

  • The higher the Flesch Index Score, the simpler the text and the easier it is to read.
  • The lower the Flesch Index Score, the simpler the text and the easier it is to read.

Q7. How much time did you spend on the programming assignment?

  • <1 hour
  • 1-2 hours
  • 2-3 hours
  • 3-4 hours
  • 4-5 hours
  • 5+ hours

Q8. How difficult did you find the programming assignment?

  • Very Easy
  • Easy
  • Somewhat Easy
  • Somewhat Difficult
  • Difficult
  • Very Difficult

Q9. How much did you enjoy the programming assignment?

  • I really enjoyed the programming assignment
  • I enjoyed the programming assignment
  • I’m neutral about the programming assignment
  • I did not enjoy the programming assignment
  • I really did not enjoy the programming assignment

Data Structures and Performance Week 03 Quiz Answers

Module and After Programming Assignment Quiz

Q1. Consider the function f(n) = 3nlog_2(n) + 100log_2(n)f(n)=3nlog2​(n)+100log2​(n). What is the tightest Big-O class for f(n)f(n)?

  • O(nlog(n))O(nlog(n))
  • O(n^2)O(n2)
  • O(n)O(n)
  • O(log(n))O(log(n))

Q2. Does the following equality give the tightest Big-O equivalence class?

log_{10}(n) + 25log_5(n) = O(log_2(n))log10​(n)+25log5​(n)=O(log2​(n))

  • Yes
  • No

Q3. Consider the following code:

int sumSome(int[] arr{   
int sum = 0;   
for (int i=0; i<arr.length;  i++) {      
for (int j=0; j<arr.length; j+=2) {         
if (arr[i] > arr[j])            
sum += arr[i];      
}   
}   
return sum;
}

What is the tightest Big-O running time for this code in terms of the length of the array, nn?1 point

  • O(n)O(n)
  • O(log(n))O(log(n))
  • O(nlog(n))O(nlog(n))
  • O(n^2)O(n2)

Q4. Consider the following code

int sumSome(int[] arr{   
int sum = 0;   
for (int i=0; i<arr.length;  i++) {      
for (int j=1; j<arr.length; j = j*2) {         
if (arr[i] > arr[j])            
sum += arr[i];      
}   
}   
return sum;
}

What is the tightest Big-O running time of this code in terms of the length of the array, nn?

  • O(n^2)O(n2)
  • O(nlog(n))O(nlog(n))
  • O(n)O(n)

Q5. You have two programs, program A and program B, that do the same thing. Program A runs in O(n)O(n) (tightest bound) and program B runs in O(n^2)O(n2) (tightest bound) in the best, worst and average cases. A graph representing each program’s behavior is shown below. This graph is an approximation of the real values.Data Structures and Performance Quiz Answers - Networking Funda

True or false: if you give both programs the same input, program A will always run faster than program B no matter what the input was.

  • True
  • False

Q6. You have two programs, program A and program B, that do the same thing, but may or may not contain exactly the same instructions. Both programs run in O(n)O(n) (tightest bound) in the best, worst and average cases.

True or false: If you give both programs the same input, you can be sure they will take the same amount of time to complete no matter what the input was

  • True
  • False

Q7. What is the tightest Big-O running time to calculate the Flesch readability score for the BasicDocument class, where n is the length of the document?

  • O(n^2)O(n2)
  • O(1)O(1)
  • O(n^3)O(n3)
  • O(n)O(n)

Q8. What is the tightest Big-O running time to calculate the Flesch readability score the first time in the EfficientDocument class, where n is the length of the document, assuming you include the time it takes to initialize the numSyllables, numWords, and numSentences variables?

Note that this is not necessarily the running time that you saw when you plotted the graph of your EfficientDocument running time when you did your benchmarking. That time included the time to initialize the numSyllables, numWords and numSentences variables.

  • O(1)O(1)
  • O(n)O(n)
  • O(n^2)O(n2)

Q9. What is the tightest Big-O running time to calculate the Flesch readability score in the EfficientDocument class, where n is the length of the document, assuming you DO NOT include the time it takes to initialize the numSyllables, numWords, and numSentences variables (i.e. do not include the time taken by processText)?

  • O(1)O(1)
  • O(n)O(n)
  • O(n^2)O(n2)

Q10. Which of the following graphs looks most like the graph you (should have) produced in part 2 of the programming assignment? We are looking for you to compare the shapes of the functions only–these graphs are much smoother than what you would have seen. Also, ignore the specific numbers, and concentrate on the shapes and the relationship between the two lines. Note that the correct answer assumes that you have correctly implemented your two Document classes and your DocumentBenchmarking class.

Data Structures and Performance Quiz Answers - Networking Funda
Data Structures and Performance Quiz Answers - Networking Funda
Data Structures and Performance Quiz Answers - Networking Funda
  • correct answer
Data Structures and Performance Quiz Answers - Networking Funda

Data Structures and Performance Week04 Quiz Answers

Quiz : Content and Programming Assignment

Data Structures and Performance Quiz Answers - Networking FundaQ3. Assume that no nodes have been deleted from this tree.

  • There is only one insertion order that could have produced this tree.
  • 32 must have been inserted before 45
  • 42 must have been inserted first.
  • A different insertion order with the same values could give a different tree structure.
  • 32 must have been inserted before 12

Q4. Which of the following statements are true about the running time of binary search trees? Assume that when we use big-O notation we mean the tightest big-O bound.

  • The tightest possible worst case time to find an element in an arbitrary BST is O(n)
  • The tightest possible worst case time to find an element in an arbitrary BST is O(log(n))
  • The tightest possible worst case time to find an element in a balanced BST is O(log(n))
  • Inserting sorted data into an unbalanced BST leads to the worst case BST structure (i.e. a structure where finding an element will take the longest).
  • The tightest possible worst case time to find an element in a balanced BST is O(n)

Q5. From your benchmarking of the DictionaryLL and DictionaryBST structures you implemented, which structure is the better choice?

  • DictionaryLL
  • They are about the same
  • DictionaryBST

Q6. In your benchmarking of the DictionaryBST structure, you probably found that the time to find words did not significantly increase as the Dictionary got larger. Which of the following is the most likely reason for this behavior?

  • log(n) is sufficiently small and grows sufficiently slowly that other factors (e.g. memory use) had a bigger effect on the running time than the size to find the word in the dictionary.
  • We were measuring the best case performance of the dictionary, which does not change as the dictionary size grows.
  • The running time to find an element in a balanced BST is O(1) so we would not expect the running time to get larger as the dictionary got bigger.
Get all Quiz Answers of Robotics Specialization

Course 01: Robotics: Aerial Robotics Quiz Answers

Course 02: Robotics: Computational Motion Planning Quiz Answers

Course 03: Robotics: Mobility Quiz Answers

Course 04: Robotics: Capstone

Team Networking Funda
Team Networking Funda

We are Team Networking Funda, a group of passionate authors and networking enthusiasts committed to sharing our expertise and experiences in networking and team building. With backgrounds in Data Science, Information Technology, Health, and Business Marketing, we bring diverse perspectives and insights to help you navigate the challenges and opportunities of professional networking and teamwork.

Leave a Reply

Your email address will not be published. Required fields are marked *