CS2420 - Module 3 Quiz Questions
The method call key.hashCode() returns a value between −231���231−1However, the array that we use to store our items has length M Which of the following expressions is best suited to transform the hash code to a valid index of our array? ( key.hashCode() & 0x7fffffff ) % M Math.abs( key.hashCode() ) % M key.hashCode() % M
( key.hashCode() & 0x7fffffff ) % M
Assume you have a 2-3 tree, that contains N elements (N keys) Which big-O best describes the splitting of a temporary 4-node
1
2 nodes have [ Select ] ["1", "3", "2"] key(s) and [ Select ] ["3", "4", "2"] children (subtrees) 3-nodes have [ Select ] ["3", "2", "1"] key(s) and [ Select ] ["4", "2", "3"] children (subtrees)
1 2 2 3
Check ALL statements that apply to a 3-node in a 2-3 tree. All keys in the left subtree are smaller than the smaller key All keys in the middle subtree are bigger than the smaller key and smaller than the bigger key All keys in the right subtree are bigger than the bigger key All keys in the middle subtree are bigger than the bigger key and smaller than the smaller key
1, 2, 3
Complete the sentence below: The height of a left-leaning red-black BSTs is always less or equal to ________________ . square root of N N log N 2 log N log N
2 log N
Check ALL that applies for 2d trees: 2d trees are most efficient when the points are evenly distributed over the plane On odd levels 2d trees use the y-coordinate as key ( divide top | bottom ) 2d trees recursively partition the plane into two halfplanes On even levels 2d trees use the x-coordinate as key (divide left | right)
2, 3, 4
Assume you have 1000 items that need to be stored in a hash table and you use separate chaining. Which array size should you choose for your hash table if you want constant time searches and you don't want to allocate too much extra memory?
200
The video introduced the Birthday problem by stating that we can expecttwo balls in the same bin after square root of pi x M over 2 tosses. How does this relate to Birthdays? Once we have approximately _____________ people in a room we can expect that 2 of them celebrate their Birthdays on the same day
24
In Java a BST is a reference to a root Node. In Prof. Sedgewick's implementation each node consists of ________________ . 4 fields: a key, a value, a left subtree, and a right subtree 3 fields: the key, a left subtree, and a right subtree 3 fields: the value, a left subtree, and a right subtree 2 fields: a left subtree, and a right subtree
4 fields: a key, a value, a left subtree, and a right subtree
Assume a new item with a new key is added to the hash table, that uses separate chaining as described in Prof Sedgewick's video. Which of the following best describes the process? A) map key to integer i insert new item at the front of i-th chainB)map key to integer i insert new item at the end of i-th chainC)map key to integer i replaces existing item on position i
A
Check ALL options below that correctly descriptions breadth first search. Breadth first search is not a recursive algorithm Breadth first search solves the shortest path problem Breadth first search examines vertices in increasing distance from s
All
Check ALL statements that are true. kd trees allow us to do efficient processing of sets of points in space kd trees are very flexible and useful kd trees are extension of BSTs
All
Check ALL statements that are true Every path from the root to a leave has the same length Most but not all 2-3 trees are perfectly balanced 2-3 trees allow for 2-nodes as well as 3 nodes 2-3 trees are generalizations of the binary search trees (BSTs) 2-3 trees are an implementation of balanced trees in guaranteed logarithmic time
All but 2
Which of the following input sets should you choose if it is your goal to create an efficient binary search tree? It doesn't make a difference. All three orders are equally good All elements in descending order All elements in ascending order All elements in random order
All elements in random order
One of the statements below is NOT true. Find the wrong statement All keys in the left subtree are smaller than the key of the parent node A BST is a binary tree in symmetric order in a BST each node has a left and a right subtree All keys in the right subtree are greater or equal to the key in the parent node A BST can be null
All keys in the right subtree are greater or equal to the key in the parent node Btw, symmetric order means inorder traversal yields keys in ascending order
Class Path has two arrays (fields) that keep track of vertex related information while executing the depth-first search. Which of the following best describes the two fields? A) an array that stores for each vertex whether the vertex has already been visited an array that stores the next vertex (where we go from here) B) an array that stores for each vertex whether the vertex has already been visited an array that stores the prior vertex (where we came from) C) an array that stores for each vertex whether the vertex has already been visited an array that stores the path from the origin to the current vertex Caveat: the letters might not be listed in order
B
In this video Prof. Sedgewick introduces a number of interesting graph challenges.If one of those challenges was part of the final code and you were asked to pick one in the best interest of the class, which one should you choose? Find a cycle that visits every vertex exactly once Is a graph bipartite? Lay out a graph in the plane without crossing edges Find a cycle that uses every edge exactly once Answer Find a cycle Bridges of Koenigsberg Are two graphs identical except for vertex names?
Find a cycle
Below you find some descriptions of depth-first search.However, one of the descriptions is incorrect.Find the description that does NOT apply to depth-first search. It is a systematic search through a graph it marks v as visited and recursively visits all unmarked vertices that are adjacent to v It looks at all adjacent vertices before it looks at vertices that are farther away from v It mimics maze exploration
It looks at all adjacent vertices before it looks at vertices that are farther away from v
If the array is too large compared to the number of keys, we use up too much memoryIf the number of keys is too large compared to the size of the array, the search is too slow. Let's assume that the size of the array is M and the number of keys is N.Complete the sentence below:If ____________ the number of probes for a search hit is about 3/2. N / M ~ 0.7 N / M ~ 0.9 N / M ~ 0.25 N / M ~ 0.5
N / M ~ 0.5
Which of the following symbol table implementations has the best guaranteed performance when searching for an element? Unordered List Ordered Array BST (Binary Search Tree)
Ordered Array (lg N worse case, lg N average case) BST is N worse case, 1.38 lg N average case sequential search is N worse case, N/2 average case
During the insertion of elements ( keys) we sometimes end up with red links that are leaning in the wrong direction. What should be done?
Perform one or more rotations. This will re-align the tree.
match the algorithm on the left to the description on the right Depth-first search Breadth-first search
Put unvisited vertices on stack Put unvisited vertices on queue
Assume you have a left-leaning red-black BST that includes N elements (keys). All rotations in a left-leaning red-black tree are local operations. Which of the following best describes what 'local' means in this context? Rotations take a constant amount of operations that is independent of N The number of elements affected by a rotation are less than the square root of N All elements affected by a rotation are from the same subtree
Rotations take a constant amount of operations that is independent of N
Which of the following causes the height of a 2-3 tree to increase? Splitting a temporary 4-node at the root. Inserting a new element into a 3-node Adding a new node to a leave
Splitting a temporary 4-node at the root.
Class Path returns the path as an Iterable<Integer>.Iterable is an interface. What is actually returned in an instance of a class that implements the interface Iterable<E>.What is the type of the variable that stores and return the path? LinkedList<Integer> Stack<Integer> Bag<Integer> Queue<Integer>
Stack<Integer>
For complicated keys it can be expensive to calculate a good hash code.There are different ways to respond to such a situation. Only two of the options below should be considered. Which are these two (2) options? Come to the conclusion that calculating the hash code won't affect the overall performance even for complex calculations Simplify the hash code even if it means that the keys are no longer uniformly distributed Store the hash code so it has to be calculated only once Consider using left-leaning red-black BSTs for your symbol table implementation
Store the hash code so it has to be calculated only once Consider using left-leaning red-black BSTs for your symbol table implementation
The video discussed three different ways to represent a graph: using a list of edges, an adjacency matrix, or adjacency lists. A frequent task is to iterate over all the vertices that are adjacent to vertex v. Match the description on the left to the graph representation on the right To iterate through the adjacent vertices you only have to go through the adjacent vertices To iterate through the adjacent vertices you have to go through all the vertices To iterate through the adjacent vertices you have to go through all the edges
adjacency list adjacency matrix list of edges
Both the Graph API and the Digraph API include the following method: public Iterable<Integer> adj (int v) In class Graph it returns all the vertices adjacent to a given vertex. In class Digraph it returns ____________ . all vertices, that can be reached directly from v all vertices that have any edge connecting it with v (either direction) all vertices, that have an edge pointing to v
all vertices, that can be reached directly from v
Many real-world graphs are large and sparse. Because of that Prof. Sedgewick uses ______________ to implement the Digraph. a list of edges an adjacency matrix a 2D array an adjacency list
an adjacency list
In a left-leaning red-black BST red links [ Select ] ["are always right leaning", "are always left leaning", "can be left or right leaning"] and black linkes [ Select ] ["can be left leaning or right leaning", "are always right leaning", "are always left leaning"] .
are always left leaning can be either
In the video Prof. Sedgewick talks about the processing of geometric data using symbol tables and BSTs. The idea is that the ____ are geometric data not just simple strings or numbers.
keys
Assume we have N points in a given space and we want to divide the space up into a M x M grid. Which of the following provides a good rule of thumb when choosing the right size of M for the M x M grid? Complete the sentence below: M should be _______________ .
sqrt(N)
Deleting an element from a BST using Hibbard deletion takes time proportional to __________ .
sqrt(N)
Both hash tables and red-black trees can be used to implement symbol tables.Which one should you choose? Match the requirement on the left to the implementation on the right You write code for an auto-pilot. It is very important that all symbol table look-ups execute in the specified time You write code for a game that uses a lot of animation. Speed is your first concern when selecting a symbol table implementation
left-leaning red-black BST hash table (this is bc red black bst have a guaranteed time)
When alternating inserting and deleting elements using Hibbard Deletiom, over time the BST becomes ___________________ . larger, but the balance remains unaffected more balanced slower, but the balance remains unaffected less balanced
less balanced
Breadth first search (BFS) computes the shortest path from s to all other vertices in ___________ timer. quadratic linear logarithmic linearithmic
linear
Prof. Sedgewick introduced two ways to implement a hash table: separate chaining and linear probing.These methods have different advantages and disadvantages. [ Select ] ["separate chaining", "linear probing"] typically has better cache performance [ Select ] ["separate chaining", "linear probing"] is less sensitive to poorly-designed hash functions
linear probing separate chaining
Which of the following best describes a typical nearest neighbor search in a 2d tree? N log N N log N
log N
In the grid implementation we divide the space into an M-by-M grid of squares If M is too big it will require too much _____ If M is too small it will require too much ______
memory time
The Graph API provides an overloaded constructor that reads in a graph from an input stream Which of the following best describes the expected file format?
number of vertices number of edges v1 v2 etc
The order of growth of running time for 1D range search depends on the data structure that was used when implementing insert, range count, and range search. Match the description on the left to the data structrue on the right Fast range count and range search but O(N) on insert O(log N) on insert and range count, O( R + log N) on range search Fast insert but O(N) on range count and range search
ordered array BST unordered list
The basic plan of hashing is the following: We use the key to calculated the appropriate array index and that's where we'll store the item. There are a number of issues, that come with hashing.Below you find four options.Only three of them describe issues related to hashing.Which is the option that does NOT belong here? compute the hash function override compareTo test for equality collision resolution
override compareTo
In order to implement depth-first search Prof. Sedgewick uses a class called Path. It has two method. Which are the two methods of the Path API? pathTo and hasPathTo getPath and hasPath getPath and numberOfEdges pathTo and numberOfEdges
pathTo and hasPathTo
There are two invariants. Those are things that are always true for a left-leaning red-black BST. Check the two (2) invariants: largest element is at the root perfect black balance symmetric order
perfect black balance symmetric order
What happens when a vertical line segment is hit? perform a range search on the BST to find all intersecting horizontal lines all leave nodes in the BST are intersecting horiziontal line segments remove all intersecting horizontal lines from the BST insert the line segment into the BST
perform a range search on the BST to find all intersecting horizontal lines
Task: Given N horizontal and vertical line segments, find all intersections. Match the algorithm on the left to order of growth of the running time on the right Check all pairs of line segments for intersection sweep-line algorithm
quadratic linearithmic
Complete the sentence below: When we execute the sweep-line algorithm and we hit the right end point of a horizontal line segment we ______________ . add an end-of-line marker to the entry in the BST remove the line segment from the BST continue. ( no special treatment is necessary )
remove the line segment from the BST
Fill in the blank: For a symbol table that is implemented with a BST, all ordered symbol table operations except for the iteration take time proportional to ____________ .
the height of the tree Ordered operations such as min, max, floor, ceiling, rank
Complete the sentence below: When connecting two elements (keys) with a red connection ____________ . the smaller key is the root either key can be the root the larger key is the root
the larger key is the root
The Digraph has a method called reverse. It reverses _______________ .
the whole graph an edge between two vertices v1 and v2 the edges to all the vertices adjacent to a given vertex v
In order to implement the topological sort we do the following: run DFS return the vertices in reverse post-order. While running DFS vertices are pushed on the stack as soon as ____________ . they are encountered they are done
they are done
Prof. Sedgewick introduced an approach of deletion where the element didn't actually get removed from the tree. Instead a marker was used to indicate that this element should no longer be considered equal during searches. How did he call this special marker? deleter tombstone remover killer
tombstone
Sometimes we need the shortest path from any vertex in a given set of sources (vertices) to any of the other vertices. Which of the following solutions was introduced in the video? call BFS for each of the source vertices modify BFS by adding a loop that calculates the paths for all source vertices use BFS but when initializing the queue enqueue all source vertices
use BFS but when initializing the queue enqueue all source vertices
Sometimes we need to use breadth first search (BFS) but we don't know all the vertices because there are too many. What should be done use BFS with an implicit digraph (enqueue vertices as they are discovered) Create an array of the known vertices and perform BFS on them Use depth first search (DFS) instead
use BFS with an implicit digraph (enqueue vertices as they are discovered)
Assume you use a digraph to schedule a set of tasks, that have precedence constraints. In such a graph the tasks should be the vertices and the constraints should be the edges vertices edges
vertices edges
Complete the sentence below: For Red-Black BSTs, When we add a new node we always add it _______________ . with a black link to the left child of the parent node to the right child of the parent node with a red link
with a red link
In the sweep-line algorithm we consider each [ Select ] ["y coordinate", "x coordinate"] as an event. Whenever we hit the left end point of a horizontal line segment we insert the [ Select ] ["y coordinate", "x coordinate"] of that line segment into a BST.
x coordinate y coordinate
Java provides customized implementations of hashCode for classes that are commonly used as keys like Integer, Double, String, etc. In Java the type double is 8 bytes long. However, the hashCode returned is a 4 byte int.How is this 4 byte (32 bit) integer calculated? return xor of the most significant 32 bits with the least significant 32 bits return the sum of the most significant 32 bits and the least significant 32 bits return the most significant 32 bits return the least significant 32 bits
return xor of the most significant 32 bits with the least significant 32 bits
Hashing is preferred over red-black trees if we have_________ is easy to compute and _______.
short keys, where the hash function we don't need any of the ordered symbol table operations
Complete the sentence below: A(n) __________ traversal of the a 2-3 tree yields the keys in ascending order post-order level-order pre-order in-order
in order
Sedgewick talked about "perfect black balance" What did he mean? Every path from the root to a null link has the same number of black links The number of black links and red links is always the same Every subtree, that includes only black links, is perfectly balanced
Every path from the root to a null link has the same number of black links
Complete the sentence below: Two vertices are __________ if there is a path between them compound combined connected
connected
Connect each description on the left to a term on the right A path whose first and last vertices are the same A sequence of vertices connected by edges A set of vertices connected pairwise by edges
cycle path undirected graph
Cycle detection is an important application of______ in digraphs.
depth first search
Below you find statements about left-leaning red-black BSTs. One of the statements is incorrect. Which one is the statement that is false? A 3-node is implemented by connecting two nodes with a red link Left-leaning red-black BSTs are a representation of a 2-3 tree as a BST Every path from the root to a null link has the same number of red links No node has 2 red links connected to it
Every path from the root to a null link has the same number of red links
The video discussed three different ways to represent a graph: using a list of edges, using an adjacency matrix, or using adjacency lists. Match the graph representation on the left to the memory requirement on the right list of edges adjacency matrix adjacency lists
E V*V E + V
Fill in the blank: The number of compares that is required to search for an element is ___________ . number of leaf elements of the BST depth of node depth of node + 1 depth of node - 1
depth of node + 1
Which of the following best describes searching in a linear probing hash table? A) calculate index ( i ) based on hash code of the keyif the element is on index i it is foundotherwise it is not in the hash tableB) calculate index ( i ) based on hash code of the keyif the element is on index i it is foundotherwise check the next index until the element is found or an empty index is reached C)calculate index ( i ) based on hash code of the keyif the element is on index i it is foundotherwise check the elements in the linked list until the key is found or the end of the list is reached (in that case the key is not in the hash table) Caveat: The letters might not be listed in order B A C
B
Which of the following best describes the breadth first algorithm? A) Put s on stack and marks s as visitedThen repeat until queue is empty: remove vertex v from stack add to stack all unmarked vertices adjacent to vand mark them as visited B) Put s on queue and marks s as visited.Then repeat until queue is empty: remove vertex v from queue add to queue all unmarked vertices adjacent to v and mark them as visited C) Repeat until queue is empty: add to queue all unmarked vertices adjacent to vand mark them as visited remove vertex v from queue
B
The adjacency list implementation uses a one-dimensional array, whose indices correspond to vertices. What is the type of the array in Prof. Sedgewick's adjacency-list graph implementation? int[] List<Integer>[] Graph[] Bag<Integer>[]
Bag<Integer>[]
Connected Components and Union Find have both similarities and differences. [ Select ] ["Union Find allows", "Connected Components allows", "Both allow"] us to find out whether two vertices are connected [ Select ] ["Both provide", "Union Find provides", "Connected Components provides"] more functionality. It allows us to add vertices and to check whether they are connected in arbitrary order [ Select ] ["Connected Components starts out", "Union Find starts out", "Both start out"] with the finished graph and only checks whether two vertices are connected [ Select ] ["Both", "Only Union Find", "Only Connected Components"] can determine in constant time whether two vertices are connected.
Both allow Union find provides Connected components starts out Only connected components
Class CC (connected components) and class Path (depth first search) have both similarities and differences. [ Select ] ["Class Path has", "Both have", "Class CC has"] a field of type boolean[] that keeps track whether a vertex has already been visited. Both have a field of type int[] that associates a number with the vertices. However, which number is associated with the vertices differs. [ Select ] ["Class CC stores", "Class Path stores", "Both store"] the number of the previous vertex Class CC stores the component number
Both have Both have Class Path stores Class CC stores
Prof. Sedgewick used a design pattern that decoupled the graph data from the graph processing. Which of the following best describes this design pattern? A) create a subclass from Graph that knows how to process the graph create an instance of that subclass ( G ) query G for information. B) create separate classes for different graph processes create an instance of that new class ( GP ) query GP for information C) create a Graph object ( G ) pass G to a graph-processing routine query the graph-processing routine for information Caveat: the letters might not be listed in order
C
All classes in Java inherit the method hashCode(), which returns an integer. The Java language has built-in rules for the implementation of hashCode. Below you find some statements regarding the method hashCode. One of them is false.Which of the following statements is NOT true? A) if ( x.equals(y)) then we know for sure that x.hashCode() == y.hashCode() B) if (x.hashCode() != y.hashCode()) then we know for sure that ( ! x.equals(y)) C) if ( ! x.equals(y)) then we know for sure that x.hashCode() != y.hashCode()
C it's a highly desirable feature but we don't know
Below you find some descriptions of connected components.One of these descriptions is incorrect. Find the wrong description. Connected Components determine whether v1 is connected to v2 in constant time Connected Components are like Union Find where all the trees are flat Connected Components partition vertices into connected components. Connected Components uses breadth first search to find the connected components
Connected Components uses breadth first search to find the connected components
Which of the following are good guidelines for hashCode implementations of user-defined types? You can select multiple answers Use the fields with primitive types to compute the hash code Consult an expert in performance critical situations Use the whole key to compute the hash code Use the last 3 digits / characters of the various fields to compute the hash code
Consult an expert in performance critical situations Use the whole key to compute the hash code
Below you find a number of graph examples.All of them are digraph examples except for one. Which example is NOT digraph related? Create a graph that shows how to navigate through a maze Create a graph that models the street connections of lower Manhatten Create a graph that shows all placed phone calls within a company Create a graph that shows the spread of an infectious disease
Create a graph that shows how to navigate through a maze
Check ALL options that describe DAGs. DAGs have no cycles DAGs have directed edges DAGs are used in topological sorting
DAGs have no cycles DAGs have directed edges DAGs are used in topological sorting
Match the description on the left to the term on the right set of vertices connected pairwise by directed edges number of arrows (directed edges) coming in to the vertex number of arrows (directed edges) leaving the vertex
Digraph Indegree Outdegree
1D range search is an extension of the ordered symbol table API that we saw in prior videos. The new features are range search and range count. Which of the following is NOT and example of a 1D range search? Find all employees that earn between $100,000 and $250,000 in a database. Find all conference rooms that accomodate at least 300 people but no more than 500. Find all points on a line that are greater than n1 and less than n2. Find all students that have an income less than $10,000 or have a tuition waver.
Find all students that have an income less than $10,000 or have a tuition waver.
Depth First Search allows us to write simple solutions to a number of digraph problems. Below you find a list of digraph problems.Three of them can use DFS as a basis for a simple solution. However, one of the problems cannot be solved with depth first search. Which one is it? Reachability Finding a path from v1 to v2 detect direct cycles Finding the shortest path from v1 to v2
Finding the shortest path from v1 to v2
In order to provide an efficient implementation of size(), rank(), and select() Prof. Sedgewick does the following: He dynamically calculates the size of the tree based on the sizes of the left and right subtrees He adds a field count to the root of the tree He adds a field count to each node
He adds a field count to each node
Which of the following best describes insertion into a BST? If less, go left; if greater, go right, if null insert If less or equal, go left; if greater, go right, if null insert If less or equal, go left; if greater or equal, go right, if null insert If less, go left; if greater or equal, go right, if null insert
If less, go left; if greater, go right, if null insert
The color information of the link is stored in the Node class Which of the following describes Prof. Sedgewick's implementation of the color information? If the color is set to true (RED) that means that the incoming link is red If the color is set to 0 (BLACK) that means that both connections to the children are red If the color is set to 1 (RED) that means that the connection to the right child is red If the color is set to -1 (RED) that means that the connection to the left child is red
If the color is set to true (RED) that means that the incoming link is red
Below you find some statements about linear probing hash tables. One of the statements is incorrect. Which one is the false statement? If the given index is free the element (key) is stored right there If the given index is NOT free the element (key) is stored in a linked list The hash code is used to map the key to an index of the array If the given index is NOT free the element (key) is stored in the next available index Elements (keys) are stored in an array
If the given index is NOT free the element (key) is stored in a linked list
The performance of hash tables is based on the uniform hashing assumption.This can cause issues in a number of situations. Below you find 2 examples where the hash function can cause a problem.Check both of these two (2) examples? If a guaranteed performance is required (e.g. hard real time systems) If a left-leaning red-black binary search tree is used If the hash code function is known and exploited to create a denial-of-service attack
If the hash code function is known and exploited to create a denial-of-service attack If a guaranteed performance is required (e.g. hard real time systems)
The calculation of the hash code should not only be well distributed but also efficient (fast). In order to optimize the performance of the String hashCode implementation Java does the following: It uses the last 4 characters of the string to calculate the hashCode It addes a cookie to store the hash value It uses every 4th character to calculate the hashCode It adds a field to class String to store the hash value
It adds a field to class String to store the hash value
There are different ways to represent a graph. One possibility would be the adjacency-matrix. This is a V x V matrix of boolean value that indicates for each of the vertices whether it is connected to any other of the vertices. Nonetheless, this representation isn't used that often in real-world applications.Why not? Finding out whether two vertices are connected takes too much time The implementation is too complicated The matrix takes too much memory
The matrix takes too much memory
What is the degree of a vertex v? The number of vertices connected by a path to V The number of edges between the vertex v and the most distant vertex in the graph The number of vertices connected directly to v
The number of vertices connected directly to v
One of the following statements is incorrect.Find the false statement The same identical code is used to imiplement searching in elementary BSTs and in left-leaning red-black BSTs, Because of that left-leaning red-black trees have the exact same search performance as elementary BSTs. The same identical code is used to imiplement searching in elementary BSTs and in left-leaning red-black BSTs, Nonetheless left-leaning red-black BSTs have a better search performance (are faster) than elementary BSTs. For left-leaning red-black BSTs the implementation of many symbol table operations like search, ceiling, selection, etc. are identical to the implementation in elementary BSTs. The color of the link is ignored.
The same identical code is used to imiplement searching in elementary BSTs and in left-leaning red-black BSTs, Because of that left-leaning red-black trees have the exact same search performance as elementary BSTs. They are faster because they are better balanced.
Every undirected graph is a digraph with edges in both directions.
True
Separate chaining is a collision resolution strategy that makes use of elementary linked lists.
True
Sometimes we need to take a left-leaning red link and temporarily lean it right.
True False
Hash functions calculate a table index based on the key. Each table index should be equally likely for each key. Here are 3 suggestions to create a simple hash function for employees. Which one should you choose? Use the zip code as a hash function for employees Use the area code as a hash function for employees Use the last 4 digits of the social security number as a hash function for employees
Use the last 4 digits of the social security number as a hash function for employees
Which of the following best describes Hibbard Deletion? Version1: search for the node t that contains the key k If t has 2 children, find the successor x of t Delete x from t's right subtree Put x in the position where t used to be Version2: search for the node t that contains the key k If t has 2 children, find the predecessor x of t Delete x from t's left subtree Put x in the position where t used to be Caveat: The versions might not be listed in order
Version 1
Prof. Sedgewick's graph API represents vertices with integers between 0 and V - 1 However, sometimes graphs use other types like letters or Strings to represent vertices.How can we use Prof. Sedgewick's graph classes when the client provides the vertices as Strings (e.g. graph data where the vertices are cities and the connections indicate whether there exists a train connection between the cities) You could use a symbol table that matches the strings to integers and then use his graph classes You could tell the client to provide numbers instead of names In such a situation his graph classes can't be used.
You could use a symbol table that matches the strings to integers and then use his graph classes
While performing certain operations in left-leaning red-black BSTs you sometimes encounter a node that has 2 red links coming out (like in the image above) That corresponds to _________ of a 2-3 search tree. a 2-node a (temporary) 4-node a 3-node
a (temporary) 4-node
The grid implementation works great if the points are ______________. However, typically this is not the case. evenly distributed sorted lined up in a straight line
evenly distributed
What is the Mark-sweep algorithms used for? find unreachable code in a program finding the shortest connection between two vertices garbage collection identify intersections of lines
garbage collection
