DATA STRUCTURES - ALL QUIZZES

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Refer to the same problem. After inserting which record rehashing (the number of buckets increased from 16 to 32) was done?

"Li", 3.44

Predict output. The Point class is available under the introduction package.

(1.0. 2.0)

Predict output. The Point class is available under the introduction package. Queue

(3.0.2.0)

Consider an empty hash table with records having string keys and double values. Assume that when it is empty, there are 16 empty buckets (as Java prefers). The target load factor is 0.75. During hashing, the number of buckets is increased two-fold (from N to 2N). Now, insert the following records sequentially. Then, count the number of non-empty buckets in the table. Since the keys are strings, calculating hash values by hand could be tedious. So, using IntelliJ is highly recommended.

11

Predict the return value of the following method without using a computer

16

What would be the array's length if we were to represent the following binary tree using an array (see the slides)?

17

Assume that in a certain hash table, there are 19 records already inserted into it, and the number of buckets (size of the array) is 50. What is the current load factor?

19/50

Insert the following words into an empty trie, and count the total number of nodes in the trie, including the root node. cat, bat, dog, deer, unf, cheese

21

Consider an empty min-heap of integers and insert the following integers into it one at a time. 66, 9, 10, 5, 17, 88, 93, 31, 2 How does the array representation of the heap look like after you have inserted all the above integers?

25 10 9 17 88 93 66 31

Consider the array: 76 25 40 36 26 80 62 33 86 70 32. Assume that 36 is chosen as the pivot. Then, which one of the following looks partitioned with respect to the chosen pivot 36?

32 26 25 33 36 76 40 80 62 86 70

What is the height of the following binary tree

4

Predict output without using your computer

6

Consider the following array: 76 25 40 36 26 80 62 33 86 70 32. If we use the median of three heuristics to partition the array, which integer will be used as the pivot?

76

Now consider the same min-heap that you obtained above and execute removeMin() operation twice. How does the array representation of the resulting heap look like? 66, 9, 10, 5, 17, 88, 93, 31, 2

9 17 10 31 66 88 93

Select the preorder traversal sequence of the following binary tree

ABCDEFGHUKLMSNOP

Insert the following elements (same elements as before) into an empty Red-Black tree and count the number of times Cases 1, 2, and 3 have been used. Select the correct observation. 17, 16, 19, 20, 24, 18, 21, 22

Case 1: 2 times, Case 2: 1 time, Case 3: 1 time

Select the inorder traversal sequence of the following binary tree

EDFCGBIHJAMLSKONP

Select the postorder traversal sequence of the following binary tree

EFDGCUHBMSLOPNKA

What is the purpose of the following method?

It has no exact purpose since it crashes on certain binary trees

Insert the following integers into an empty Red-Black tree. Then, select the correct observation. 17, 16, 19, 20, 24, 18, 21, 22

Number of red nodes = 4, Number of black nodes (excluding null link nodes) = 4

What is the time complexity of the following code? Assume that both A and B contains n integers each. Since TreeSeRBTree is used, every add and contains operation will take O (log n) time in this case.

O (n log n)

What is the time complexity of the following code that checks if an ArrayList of records has unique keys (no two records have the same key)? Now, what if we use a Red-Black tree, as shown below? What is the time complexity now? Assume that the ArrayList 'register' has n records in it.

O(n log n)

In this question, you are supposed to compute the time complexity of the inorder traversal on a binary tree that has n nodes in it. At every call of the inorder method, the method does O (1) amount of work plus 2 recursive calls. So, the total time complexity equals k × O (1), where k is the total number of inorder calls made. After finding k as a function of n, figure out the time complexity. Select the best possible estimate.

O(n)

Refer to the same recursive method and assume that the method 'f' is invoked with parameter 'n. Since this is a recursive method, a call stack is maintained in the background. What is its maximum depth in this case? Give the best estimate using Big-O.

O(n)

Refer to the same recursive method and assume that the method 'f' is invoked with parameter 'n. What is its time complexity? Use the answer for the number of times the method f is invoked during the recursion to compute this.

O(n)

What is the space complexity of the following code? Assume that 'A' contains n elements and 'B' contains m elements. Select the best possible estimate. Hint: focus on the worst-case size of 'A'

O(n)

What is the time complexity of the following code that checks if an ArrayList of records has unique keys (no two records have the same key)? The code uses a binary search tree (not a red-black tree). Assume that the ArrayList 'register' has n records in it.

O(n^2)

What is the time complexity of the following code snippet?

O(п)

Refer to the same recursive method and assume that the method 'f' is invoked with parameter 'n'. Then how many times, the method f is invoked during the chain of recursive calls. Guess the answer in terms of 'n.

n + 1

True or False? If we always select the last element of the current array as a pivot, we will still have O(n?) time-complexity for quick-sort.

true

What is the purpose of the following code? Stack

Prints the reverse of the input string

What is the purpose of the following code?

Verifies whether the two ArrayLists. A and B. are disjoint (have no common integers).


Kaugnay na mga set ng pag-aaral

ATI Pharmacology Final Exam Review

View Set

Final Exam - New Jersey Life and Health

View Set

Nutrition Chapter 6 : Proteins, Amino Acids, and Vegetarian Diet

View Set