Join 75,000+ students acing their exams with Studygenie
Unlimited practice
Flashcards, multiple choice and written questions, as many as you want.
Study sets in seconds
Turn your notes and files into a set with AI.
See your progress
Always know what you've learned and what's left.
Questions in this set (37)
What is the first step of the linear time selection algorithm?
Divide the array into groups of 5 elements each.
What is the purpose of partitioning the array around the median of medians?
To determine if the kth smallest element is on the left or right side of the partition.
How is the median of medians obtained in the linear time selection algorithm?
By recursively applying the algorithm to the medians of each group.
What is the purpose of the linear time selection algorithm?
To find the kth smallest element in an unsorted array.
What is the time complexity of the linear time selection algorithm?
The algorithm runs in linear time, O(n).
What is the hash function used in the chaining example: H(k) = (3k + ji) mod 4?
A hash function that maps elements to slots 0-3 based on the value of k and a constant j.
In the open addressing example using H(k) = (3k + ji) mod 4, what value(s) of j would allow all elements 3, 8, 14, 7 to be properly inserted without collisions?
j = 1 or j = 3
What is a collision in the context of hashing?
When two different elements get hashed into the same slot.
What are the two main techniques for resolving collisions in hashing?
Chaining and open addressing.
What is the purpose of a hash function in the context of hashing data structures?
To translate elements from the universe into array index numbers.
In the chaining collision resolution technique, how are elements stored that hash to the same slot?
They are placed in a linked list within that slot.
For the key 3, what is the hash value when j = 1?
1
If the hash function used j = 2, what would be the hash value for the key 7?
2
What is the hash function used in the given example?
H(k) = (3k + ji) mod 4
For the key 14, what is the hash value when j = 0?
2
What is the first value of j that results in distinct hash values for the given keys 3, 8, 14, and 7?
3
For the hash function H(k) = (3k + j*i) mod 4, what value(s) of j allow probing to work properly for the given set of numbers {3, 8, 14, 7}?
j = {1, 3}
What is the time complexity of searching and deletion operations in a hash table with chaining, on average?
O(1 + α), where α is the load factor.
In the context of hashing with open addressing, what is the purpose of the load factor?
It represents the ratio of the number of elements to the number of slots in the hash table.
What is the purpose of the hash function H(k) = (3k + j*i) mod 4?
To determine the index of an element in a hash table using open addressing with linear probing.
What is the longest common subsequence (LCS) of the two given sequences "CATSU" and "KATS", according to the provided table?
"ATS"
In the context of dynamic programming, what is the purpose of breaking down a problem into smaller sub-problems?
To solve a complicated problem by combining optimal solutions to non-overlapping sub-problems.
What dynamic programming technique is described in the text for computing the longest common subsequence (LCS) of two sequences?
Filling out a table with values and arrows
According to the provided table, what is the length of the LCS for the sequences "CATSUA" and "KATSU"?
3
What information does each entry in the table represent when computing the LCS using dynamic programming?
The length of the LCS up to that point in the two sequences
Based on the information given, what is the actual LCS for the sequences "CATSUA" and "KATSU"?
ATS
What do the arrows in the table entries indicate when computing the LCS using dynamic programming?
The direction to trace back to find the LCS characters
What is the purpose of the table shown in the text?
To compute the longest common subsequence (LCS) of two given sequences using dynamic programming.
What is the actual LCS computed from the table for the given sequences?
AT
How are the values in the table computed for dynamic programming?
The values are computed based on the values in the cells above, to the left, and diagonally up-left, following the recurrence relation for the LCS problem.
According to the filled table, what is the length of the LCS for the given sequences?
2
What do the arrows in the table represent?
The arrows indicate the direction to trace back to find the characters in the LCS.
What is the recommended approach for the final exam cheatsheet, according to the text?
Include pseudocode for RBT operations, examples of hashing and dynamic programming, and procedures for topological sort and strongly connected components
What is the time complexity of the dynamic programming algorithm used to compute the LCS?
O(mn), where m and n are the lengths of the two input sequences
What is the purpose of the Construct-LCS function mentioned in the text?
To reconstruct the actual LCS string from the computed table
What is the purpose of the arrows in the table used to compute the LCS?
To track the optimal solution path for constructing the LCS
What is the LCS (Longest Common Subsequence) computed according to the table for the sequences "CATSATSU" and "KATSU"?