Data Structures Final

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

What is the range of values computed by the hash function H ash(X) = X mod 100? (a) 0 to 99 (b) 0 to 100 (c) 1 to 99 (d) 1 to 100 (e) none of the above

0 to 99

In a separate chaining hash table with load factor = 0:8, what is the average length of a list? (a) 0.8 (b) 1.0 (c) 1.25 (d) there is not enough information (e) there is enough information, but none of the above are correct

0.8

An access of a splay tree of n nodes results in a completely identical tree. For how many different nodes would this be possible? (a) 0 (b) 1 (c) 2 (d) n - 1 (e) none of the above

1

For an insertion of a single item into an n-item AVL tree, the maximum number of rotations (double rotations count as one rotation) is (a) 1 (b) 2 (c) approximately log n (d) approximately 1:44 log n (e) none of the above

1

How many n node binary trees with items 1, 2, ..., n have identical postorder and inorder traversals? (a) 0 (b) 1 (c) n (d) n! (e) none of the above

1

Using the text implementation, if Front and Rear have identical values, what is the size of the queue? (a) 0 (b) 1 (c) 2 (d) the answer cannot be determined (e) none of the above

1

The following items are inserted into an AVL tree: 1, 2, 3, 8, 6. How many rotations are performed? (a) no rotations (b) 1 single rotation only (c) 1 double rotation only 11 (d) 1 single rotation and 1 double rotation (e) none of the above

1 single rotation and 1 double rotation

If the above graph were undirected, then what would be the cost of its minimum spanning tree? (a) 1 (b) 10 (c) 11 (d) 12 (e) none of the above

10

The height of the tree is (a) 0 (b) 1 (c) 2 (d) 3 (e) none of the above

2

What item is at the root after the following sequence of insertions into an empty splay tree: 1, 11, 3, 10, 8, 4, 6, 5, 7, 9, 2? (a) 1 (b) 2 (c) 4 (d) 8 (e) none of the above

2

Insertion of a node into a doubly linked list requires how many changes to various Next and Prev pointers? (a) no changes (b) 1 Next, 1 Prev (c) 2 Next, 2 Prev (d) 3 Next, 3 Prev (e) none of the above

2 Next, 2 Prev

An algorithm takes 30 seconds for an input of size 1000. If the algorithm is quadratic, how large a problem can be solved in two minutes? (a) 2000 (b) 4000 (c) 6000 (d) 60000 (e) none of the above

2000

MODULE 1 Algorithm Analysis/Recursion Which of the following functions grows fastest? (a) n log n (b) 2^n (c) log n (d) n^2 (e) n^20

2^n

Suppose we are implementing quadratic probing with a hash function H ash(X) = X mod 100. If an element with key 4594 is inserted and the first three locations attempted are already occupied, then the next cell that will be tried is (a) 2 (b) 3 (c) 9 (d) 97 (e) none of the above

3

The following items are inserted into a binary search tree: 3, 6, 5, 2, 4, 7, 1. Which node is the deepest? (a) 1 (b) 3 (c) 4 (d) 7 (e) none of the above

4

What is the value of log 65536? (a) 1 (b) 4 (c) 16 (d) 32 (e) none of the above

4

An algorithm takes 10 seconds for an input size of 50. If the algorithm is quadratic, approximately how long does it take to solve a problem of size 100? (a) 10 seconds (b) 20 seconds (c) 40 seconds (d) 100 seconds (e) none of the above

40 seconds

Suppose a disk block stores 4096 bytes and the basic key size is 96 bytes. Assuming that pointers cost 4 bytes, what is the correct choice of M for a B-tree? (a) 41 (b) 42 (c) 43 (d) 96 (e) none of the above

41

The next four questions refer to the following directed graph: V = fV0; V1; V2; V3; V4; V5; V6g. There are the following twelve edges, with edge costs listed as the third item in the triplet: E = f(V0; V2; 4); (V1; V0; 2); (V1; V3; 3); (V3; V0; 1); (V3; V2; 2); (V3; V5; 8); (V3; V6; 4); (V4; V1; 10); (V4; V3; 2); (V4; V6; 7); (V5; V2; 2); (V6; V5; 1)g. The shortest weighted path from V4 to V5 has weight (a) 2 (b) 4 (c) 7 (d) 8 (e) none of the above

7

Which of the following statements about sorting five elements is the strongest statement that is directly implied by the information theoretic lower bound? (a) 6 comparisons are sufficient (b) 6 comparisons are necessary and sufficient (c) 7 comparisons are necessary (d) 7 comparisons are sufficient (e) 7 comparisons are necessary and sufficient

7 comparisons are necessary

The following items are inserted into a binary search tree: 8, 3, 4, 9, 5, 6, 2, 1, 7. Which item is placed at a root? (a) 1 (b) 4 (c) 8 (d) 9 (e) none of the above

8

How is deletion performed in a splay tree? (a) If the node is found, it is replaced with the smallest node in its right subtree, which itself is recursively deleted. (b) It the node is found, it is replaced with the largest node in its left subtree, which itself is recursively deleted. (c) A single splay is performed which places the deleted node in a leaf; that node is then easily removed (d) A single splay is performed which places the deleted node at the root; it is deleted and the two subtrees are reattached by using a second splay (e) none of the above

A single splay is performed which places the deleted node at the root; it is deleted and the two subtrees are reattached by using a second splay

Which operation is not supported in constant time by a double-ended queue (deque)? (a) Insertion as the front or rear item (b) Access of the front or rear item (c) Deletion of the front or rear item (d) Access and deletion of the minimum item (e) all of the above are supported

Access and deletion of the minimum item

Which of the following data structures has the strongest height guarantee? (a) AVL tree (b) B-tree of order 3 (c) B-tree of order 5 (d) splay tree (e) 2-3 tree

B-tree of order 5

What operation is supported in constant time by the doubly linked list, but not by the singly linked list? (a) Advance (b) Backup (c) First (d) Retrieve (e) all of the above are always constant time

Backup

Which of the following is the strongest lower bound for sorting when ordering information is obtained only by adjacent comparisons? (a) O(n log n) (b) O(n^2 ) (c) Beta(n log n) (d) Beta(n^2 ) (e) none of the above is a valid lower bound for this problem

Beta(n^2 )

What happens when wraparound is implemented for a queue? (a) If Front advances past the last array position, it is reset to the first array position. (b) If Rear advances past the last array position, it is reset to the first array position. (c) Both (a) and (b) (d) Neither (a) nor (b)

Both (a) and (b)

Let C(X) be the number of leaves in a binary tree rooted at T. Assume that IsLeaf(T) returns 1 if T is a leaf. Which of the following observations leads to a recursive implementation? (a) C(T):=C(T.Left)+C(T.Right) (b) C(T):=C(T.Left)+C(T.Right)+1 (c)C(T):=C(T.Left)+C(T.Right)+IsLeaf(T) (d)C(T):=C(T.Left)+C(T.Right)+IsLeaf(T)+1 (e) none of the above

C(T):=C(T.Left)+C(T.Right)+IsLeaf(T)

Which statement, placed in the list package implementation, inserts an item X after position Current? (a) Current := new Node'( X, Current ); (b) Current := new Node'( X, Current.Next ); (c) Current.Next := new Node'( X, Current ); (d) Current.Next := new Node'( X, Current.Next ); (e) none of the above

Current.Next := new Node'( X, Current.Next );

Which of the following is an inorder traversal of the tree? (a) ABCDE (b) ABDEC (c) DBEAC (d) DEBAC (e) none of the above

DBEAC

Which of the following algorithms solves the positive weighted single source shortest path problem? (a) breadth first search (b) depth first search (c) Dijkstra's algorithm (d) Kruskal's algorithm (e) Prim's algorithm

Dijkstra's algorithm

For the linked list implementation of the queue, where are the enqueue and dequeues performed? (a) Enqueue in front of the first element, dequeue the first element (b) Enqueue after the last element, dequeue the last element (c) Enqueue after the last element, dequeue the first element (d) Enqueue in front of the first element, dequeue the last element (e) Enqueue after the first element, dequeue the first element

Enqueue after the last element, dequeue the first element

Which of the following statements is true? (a) A topological ordering exists in every directed graph (b) Every acyclic graph has at least one topological ordering (c) Every acyclic graph has exactly one topological ordering (d) Every acyclic graph has at most one topological ordering (e) none of the above

Every acyclic graph has at least one topological ordering

Which operation is not efficiently supported by priority queues? (a) Delete Min (b) Find (c) Find Min (d) Insert (e) All of the above are efficiently supported

Find

For quicksort, what do I and J do when they see keys equal to the pivot? (a) I stops, J stops (b) I stops, J goes (c) I goes, J stops (d) I goes, J goes (e) I and J alternate between stopping and going

I stops, J stops

Which algorithm is used to compute minimum spanning trees? (a) breadth first search (b) depth first search (c) Dijkstra's (d) Kruskal's (e) none of the above

Kruskal's

If a header node is used, which of the following indicates a list L with one item? (a) L.Header.Next = null 6 (b) L.Header.Next /= null (c) L.Header.Next /= null and then L.Header.Next.Next /= null (d) L.Header.Next /= null and then L.Header.Next.Next = null (e) none of the above

L.Header.Next /= null and then L.Header.Next.Next = null

Which of the four operations below can be used to implement the other three for the skew heap? (a) Decrease Key (b) Delete Min (c) Insert (d) Merge (e) none of the above

Merge

What is the running time of the following routine? // Check if N is prime function Is_Prime( N : Integer ) return Boolean is I : Integer := 3; begin if N = 2 or else N = 3 then return TRUE; end if; if N MOD 2 = 0 then return FALSE; end if; while i * i <= N loop if N MOD i = 0 then return FALSE; else I := I + 2; end if; end loop; return TRUE; end Is_Prime; (a) constant time (b) O(log N) (c) O(N) (d) O( square-root(N)) (e) none of the above

O( square-root(N))

How much extra space is used by heapsort? (a) O(1) (b) O(log n) (c) O(n) (d) O(n^2 ) (e) none of the above

O(1)

How many times is statement 4 executed? (a) O(N) (b) O(N^2 ) (c) O(N^3 ) (d) O(N^4 ) (e) none of the above

O(N^3 )

How many times is statement 10 executed? (a) O(N) (b) O(N^2 ) (c) O(N^3 ) (d) O(N^4 ) (e) none of the above

O(N^4 )

What is the running time of the fragment? (a) O(N^4 ) (b) O(N^5 ) (c) O(N^6 ) (d) O(N^7 ) (e) none of the above

O(N^4 )

The solution to T (n) = T ((3n / 4)) + 10 with T (0) = 0 is most accurately given by (a) O(log n) (b) O(n) (c) O(n log n) (d) O(n^2 ) (e) none of the above

O(log n)

A recursive algorithm works by solving two half-sized problems recursively, with an additional linear-time overhead. The total running time is most accurately given by (a) O(log n) (b) O(n) (c) O(n log n) (d) O(n2 ) (e) none of the above

O(n log n)

n elements are inserted one by one into an initially empty binary heap. The total running time is (a) O(n) worst case and O(n) average case (b) O(n) worst case and O(log n) average case (c) O(n) worst case and O(n log n) average case (d) O(n log n) worst case and O(n) average case (e) O(n log n) worst case and O(n log n) average case

O(n log n) worst case and O(n) average case

What is amortized cost of an operation using rotate-to-root? (a) O(1) (b) O(log n) (c) O(n) (d) O(n log n) (e) none of the above

O(n)

The running time of Build Heap is (a) O(n) worst case and O(n) average case (b) O(n) worst case and O(log n) average case (c) O(n) worst case and O(n log n) average case (d) O(n log n) worst case and O(n) average case (e) O(n log n) worst case and O(n log n) average case

O(n) worst case and O(n) average case

For the linked list implementation of the stack, where are the pushes and pops performed? (a) Push in front of the first element, pop the first element (b) Push after the last element, pop the last element (c) Push after the last element, pop the first element (d) Push in front of the first element, pop the last element (e) Push after the first element, pop the first element

Push in front of the first element, pop the first element

Suppose T1(n) = O(F (n)) and T2(n) = O(F (n)). Which of the following are true? (a) T1(n) + T2(n) = O(F (n)) (b) T1(n) * T2(n) = O(F (n)) (c) T1(n) / T2(n) = O(1) (d) T1(n) = O(T2(n)) (e) none of the above

T1(n) + T2(n) = O(F (n))

Which of the following is true about the height of a node? (a) The height of a node is one less than the height of its parent (b) The height of an empty tree is 0 (c) The height of a leaf is 0 (d) The height of a tree can be larger than its depth (e) all of the above are false

The height of a leaf is 0

If the randomized primality testing algorithm (with one iteration) declares that P is prime and C composite, then which of the following is most accurate? (a) There is at most a 25 percent chance that P has been declared prime falsely and there is at most a 25 percent chance that C has been declared composite falsely (b) P is prime with 100 percent certainty but there is at most a 25 percent chance that C has been declared composite falsely (c) There is at most a 25 percent chance that P has been declared prime falsely, but C is composite with at least 100 percent certainty (d) P is prime with 100 percent certainty and C is composite with 100 percent certainty (e) All of the above statements are factually incorrect

There is at most a 25 percent chance that P has been declared prime falsely, but C is composite with at least 100 percent certainty

Which of the following can be done in O(log n) arithmetic operations? (a) Raising a number to the nth power (b) Computing the greatest common divisor of some integer and n (c) Adding two n-digit numbers (d) Two of the above (e) All of (a), (b), and (c)

Two of the above

If the start vertex is V4, then using the standard weighted shortest path algorithm, which is the last vertex to be declared known? (a) V0 (b) V1 (c) V2 (d) V4 (e) none of the above

V1

If the start vertex is V4, then using the acyclic weighted shortest path algorithm, which is the last vertex to be declared known? (a) V0 (b) V1 (c) V2 (d) the graph is not acyclic, so the acyclic algorithm should not be used (e) none of the above

V2

Which of the following is an equivalence relationship? (a) a R b if there is a path from a to b in a directed graph G (b) a R b if a and b are two people who know each other (c) a R b if a and b end in the same two digits (d) all of the above (e) none of (a), (b), (c)

a R b if a and b end in the same two digits

If the shortest path algorithm is run and a vertex is not reachable from the starting point, what happens? (a) a distance of infinity is reported (b) a distance of -1 is reported (c) a distance of zero is reported (d) the algorithm enters an infinite loop (e) the algorithm's results are undefined

a distance of infinity is reported

Items 7, 3, 11, 9, and 13 are inserted into an AVL tree. What happens when 12 is inserted? (a) no rotation is needed (b) a single rotation between some node and its left child is performed (c) a single rotation between some node and its right child is performed (d) a double rotation with a node, its left child, and a third node is performed (e) a double rotation with a node, its right child, and a third node is performed

a single rotation between some node and its right child is performed

Rehashing can be used in (a) linear probing (b) quadratic probing (c) separate chaining (d) all of the above (e) none of (a), (b), and (c)

all of the above

Which of the following, when performed by itself, is sufficient to ensure a bound of O(m log n) for m operations? (a) path compression (b) union by height (c) union by size (d) all of the above (e) none of (a), (b), and (c)

all of the above

Which of (a) to (d) is false about the binary search? (a) the input array must be sorted (b) successful searches take logarithmic time on average (c) unsuccessful searches take logarithmic time on average (d) the worst case for any search is logarithmic (e) all of the above are true

all of the above are true

ch.8 Which of the following trees can have height that is not logarithmic? (a) AVL tree (b) binary heap (c) B-tree of order 4 (d) union/ find tree, with union-by-height (e) all of the above trees must have logarithmic depth

all of the above trees must have logarithmic depth

Which of the following properties is not required for an equivalence relation? (a) reflexive (b) symmetric (c) transitive (d) all of these properties are required (e) none of these properties is required

all of these properties are required

Ch.4 MODULE 3 Which of the following traversals requires more than linear time in the worst case? (a) inorder (b) level order (c) postorder (d) preorder (e) all of these traversals are linear time

all of these traversals are linear time

The header node of a linked list (a) simplifies deletion (b) simplifies insertion (c) uses only constant extra space (d) two of the above (e) all three of (a), (b), and (c)

all three of (a), (b), and (c)

ch.9 Which of the following is a synonym for an edge? (a) arc (b) node (c) path (d) vertex (e) none of the above

arc

Which of the following data structures uses a sentinel? (a) binary heap (b) hash table (c) queue (d) stack (e) none of the above use sentinels

binary heap

Percolate up and down are used for (a) AVL trees (b) B-trees (c) circular queue (d) binary heaps (e) none of the above

binary heaps

Which of the following could be used as an efficient priority queue? (a) binary search tree (b) hash table (c) linked list (d) queue (e) stack

binary search tree

Which of the following is not a binary tree? (a) binary heap (b) binomial queue (c) skew heap (d) splay tree (e) all of the above are binary trees

binomial queue

Which of the following algorithms solves the unweighted single source shortest path problem? (a) breadth first search (b) depth first search (c) Dijkstra's algorithm (d) Kruskal's algorithm (e) Prim's algorithm

breadth first search

The UNIX editor vi allows searching in both directions, with wraparound if necessary. If the sequence of lines is stored as a linked list, which of the following is most reasonable? (a) singly linked list (b) doubly linked list (c) circular singly linked list (d) circular doubly linked list (e) none of the above

circular doubly linked list

Replacement selection is (a) arranging the initial runs on the tape in an optimal way (b) constructing the runs so they have expected length 2M (c) using K-way merging instead of 2-way merging (d) using K + 1 tapes instead of K tapes (e) none of the above

constructing the runs so they have expected length 2M

Which of the following alternatives preserves the logarithmic amortized time bound for the splay tree? (a) do not splay on unsuccessful searches (b) do not splay if an access path has fewer than log n nodes (c) replace the zig-zig with two single bottom-up rotations (d) splay on every other access (e) none of the above

do not splay if an access path has fewer than log n nodes

For the weighted shortest path problem, let dv be the cost of reaching the current vertex v, let w be adjacent to v and assume the edge cost is cv;w. Suppose that dw was the cost of reaching w prior to examining v. (Ties are broken in favor of the first path seen). Then under what circumstances is w's distance lowered? (a) dw > dv (b) dw > dv + 1 (c) dw > dv + cv;w (d) dv > dw + cv;w (e) none of the above

dw > dv + cv;w

Ch. 10 Which of the following strategies do not directly invoke recursion? (a) backtracking (b) divide and conquer (c) dynamic programming (d) two of the above do not directly invoke recursion (e) none of (a), (b), and (c) directly invoke recursion

dynamic programming

In a graph with v vertices and e edges, which of the following maximum sizes is not correct for an unweighted shortest path computation? (a) v for the number of adjacency lists (b) e for the total size of all adjacency lists (c) e for the size of the hash table that maps names to internal numbers (d) v for the size of the queue (e) all of the above are correct

e for the size of the hash table that maps names to internal numbers

Which of the following is true about the skew heap? (a) it is balanced (b) each node stores nothing besides an item and two pointers (c) the right path contains at most a logarithmic number of nodes (d) two of the above (e) all of (a), (b), and (c)

each node stores nothing besides an item and two pointers

Which data structure is generally used to implement a symbol table? (a) binary search tree (b) hash table (c) priority queue (d) queue (e) stack

hash table

Which of the following data structures does not yield an efficient comparison-based sort? (a) AVL tree (b) hash table (c) priority queue (d) all can be used for efficient sorting (e) none can be used for efficient sorting

hash table

If an element in a binary heap is stored in position i and the root is at position 1, then where is the parent stored? (a) i/2 (b) i/2 (c) 1 + (i/2) (d) 2i (e) 2i + 1

i/2

Which of the following costs are equal in a probing hash table? (a) insertion and successful search (b) insertion and unsuccessful search (c) successful search and unsuccessful search (d) insertion, successful search, and unsuccessful search (e) none of the above

insertion and unsuccessful search

CH.3 MODULE 2 Which of the following operations is not efficiently supported by a singly-linked list? (a) accessing the element in the current position (b) insertion after the current position (c) insertion before the current position (d) moving to the position immediately following the current position (e) all of the above are efficiently supported

insertion before the current position

Which of the following algorithms runs in quadratic average time? (a) heapsort (b) insertion sort (c) mergesort (d) quicksort (e) shellsort

insertion sort

Which of the following algorithms, implemented as in the text, runs in O(n) time when presented with an array of n identical elements? (a) heapsort (b) insertion sort (c) mergesort (d) quicksort (e) shellsort

insertion sort

ch.7 MODULE 6 Every node in a (min) binary heap (a) has two children (b) is no larger than its children (c) is no smaller than its children (d) has a smaller left child than right child (e) two or more of the above

is no larger than its children

The next three questions relate to the binary tree with root A. The root has left child B and right child C. B has left child D and right child E. There are no other nodes in the tree. Which of the following traversals yields ABCDE? (a) inorder (b) level order (c) postorder (d) preorder (e) two of the above

level order

Which traversal does not use a stack? (a) inorder (b) level order (c) postorder (d) preorder (e) all of these traversals uses a stack

level order

Primary clustering occurs in (a) linear probing (b) quadratic probing (c) separate chaining (d) all of the above (e) none of (a), (b), and (c)

linear probing

Which of the following algorithms requires the most extra space, on average, when implemented as in the text? (a) heapsort (b) insertion sort (c) mergesort (d) quicksort (e) shellsort

mergesort

Which sorting algorithm has the same average and worst-case time bounds (in Big-Oh) as heapsort? (a) insertion sort (b) mergesort (c) quicksort (d) shellsort (e) none of the above

mergesort

ch.7 MODULE 6 What is the basic algorithm used for external sorting? (a) finding the median (b) merging (c) selection (d) all of the above (e) none of (a), (b), and (c)

merging

A node with key 8 has a left child with key 10. Which of the following objects could this node be found in? (a) binary search tree (b) max heap (c) min heap (d) two of the above (e) none of (a), (b), and (c)

min heap

Approximately how many random numbers are using in the permutation generation algorithm in Exercise 2.7.c? (a) 1 (b) log n (c) n (d) n log n (e) none of the above

n

What is the worst-case height of a splay tree? (a) log n (b) 1:38 log n (c) 2 log n (d) n - 1 (e) n

n - 1

Which of the following functions grows fastest? (a) n + log n (b) n log n (c) n log n (d) n (e) There is a tie among two or more functions for fastest growth rat

n log n

Which of the statements (a) to (d) about splay trees is false? (a) a single access operation could examine every node in the tree (b) any n consecutive operations from an initially empty splay tree must take at most O(n log n) time (c) inserting the items 1, 2, ..., n into an initially empty splay tree takes O(n) total time. (d) the most recently accessed item is at the root (e) none of (a) to (d) is false

none of (a) to (d) is false

The first child / next sibling implementation (a) allows easy access to the parent (b) is appropriate for binary trees (c) uses C pointers per node, where C is the number of children (d) all of the above (e) none of (a), (b), and (c)

none of (a), (b), and (c)

Which of the following statements about quadratic probing is true (expensive does not include trivial operations such as multiplication or division by powers of 2; computation of the hash function is not included in the cost)? (a) an expensive division must be performed (b) an expensive mod operator must be performed (c) an expensive multiplication must be performed (d) all of the above (e) none of (a), (b), and (c)

none of (a), (b), and (c)

Approximately what is the maximum height of a binary search tree of n nodes? (a) log n (b) 1:38 log n (c) 1:44 log n (d) 2 log n (e) none of the above

none of the above

For the linked list implementation, if the stack is not empty, which of the following statements in a main procedure can be used to access the top element in the stack S? (a) S.Element (b) S.TopOfStack (c) S.TopOfStack.Element (d) TopOfStack.Element (e) none of the above

none of the above

In addition to the data and left and right pointers, for any implementation, what must be stored in each node of a splay tree? (a) the node's height (b) the node's level (c) the node's parent (d) the node's rank (e) none of the above

none of the above

In median-of-three partitioning, where is the pivot placed before partitioning begins? (a) at the start of the array (b) at the middle of the array (c) at the end of the array (d) in a temporary variable (e) none of the above

none of the above

Programs A and B are analyzed and found to have worst-case running times no greater than 150n log n and n^2 , respectively. Which of the following statements does the analysis imply? (a) Program A will run faster on average for sufficiently large n. (b) Program B will run faster on average for small n. (c) Program A is probably simpler to code than program B. (d) There exists some input for which program B takes longer than program A. (e) none of the above

none of the above

Path compression is (a) performed during Unions to make Unions faster (b) performed during Unions to make Finds faster (c) performed during Finds to make Finds faster (d) performed during Finds to make Unions faster (e) performed during Finds to make both Finds and Unions faster

performed during Finds to make Finds faster

Which of the following does not use a queue? (a) negative weighted shortest path algorithm (b) positive weighted shortest path algorithm (c) topological sort (d) unweighted shortest path algorithm (e) all of the above use a queue

positive weighted shortest path algorithm

Which traversal computes the total size of each directory in the UNIX le system? (a) inorder (b) level order (c) postorder (d) preorder (e) two or more of the above traversals could be used

postorder

In which of the following traversals is the node processed before the recursive calls to the children complete? (a) inorder (b) level order (c) postorder (d) preorder (e) none of the above

preorder

Which data structure maintains the event set in an event-driven (discrete-event) simulation? (a) binary search tree (b) hash table (c) priority queue (d) queue (e) stack

priority queue

Which of the following does the binary heap implement? (a) binary search tree (b) hash table (c) priority queue (d) queue (e) stack

priority queue

An algorithm takes 6 seconds to solve a problem of size 100 and ten minutes to solve a problem of size 1000. What is the likely running time of the algorithm? (a) constant (b) linear (c) quadratic (d) cubic (e) none of the above

quadratic

6, 8, 4, 3, and 1 are inserted into a data structure in that order. An item is deleted using only a basic data structure operation. If the deleted item is a 1, the data structure cannot be a (a) hash table (b) priority queue (c) queue (d) search tree (e) stack

queue

Jobs sent to a printer are generally placed on a (a) binary search tree (b) hash table (c) priority queue (d) queue (e) stack

queue

Which of the following algorithms has the largest big-Oh differential between average-case and worst-case performance? (a) heapsort (b) insertion sort (c) mergesort (d) quicksort (e) quickselect

quickselect

Which of the following algorithms runs in O(n log n) average time but quadratic worst-case time? (a) heapsort (b) insertion sort (c) mergesort (d) quicksort (e) shellsort

quicksort

ch.5/6 MODULE 4&5 Which of the following data structures requires more than constant average time for insertions? (a) hash table (b) queue (c) search tree (d) stack (e) all of the above have constant time insertion algorithms

search tree

Linked lists are used in (a) double hashing (b) linear probing (c) quadratic probing (d) separate chaining (e) all of the above

separate chaining

Which of (a) to (d) is false: The size of a hash table (a) should be a power of 2 for quadratic probing (b) should be a prime number for linear probing (c) should be about 2n for quadratic probing (d) should be about n for separate chaining (e) two or more of the above are false

should be a power of 2 for quadratic probing

Which data structure is used by the compiler to implement recursion? (a) hash table (b) priority queue (c) queue (d) search tree (e) stack

stack

Which data structure is used to check for balanced parentheses? (a) binary search tree (b) hash table 17 (c) priority queue (d) queue (e) stack

stack

The seed of a linear congruential generator is (a) always zero (b) occasionally zero, depending on other random events (c) the initial value (d) the multiplier (e) the period of the generator

the initial value

In a splay tree, how is the rank of a node stored? (a) an extra array stores the information (b) a linked list stores the information (c) directly, in each node (d) indirectly, by storing the size in each node (e) the rank is not stored at all

the rank is not stored at all

Which of the following statements is true about deleting the root of a binary search tree? (a) the root pointer always changes (b) the root pointer changes if it does not have two children (c) if the root has two children, its item is replaced by the largest element in the right subtree (d) all of the above (e) none of (a), (b), and (c)

the root pointer changes if it does not have two children

Which of the following is a bad case for randomized quickselect? (a) any input with K = 1 27 (b) reverse ordered input (c) sorted input (d) there are no bad inputs (e) none of the above

there are no bad inputs

What is the maximum number of nodes in a binary tree with L leaves? (a) 2L (b) 2^L (c) 2^L+1 (d) there is no maximum (e) none of the above

there is no maximum

How are elements deleted in linear probing? (a) deletion is not allowed (b) they are changed to zero (c) they are marked deleted (d) unchecked deallocation (e) none of the above

they are marked deleted

10000 random integers are generated randomly with a uniform distribution over the range 1 to 10000 inclusive. Which of the following would indicate a poor generator? (a) the average of the numbers is about 4999 (b) each number appears exactly once (c) no four consecutive numbers are all even (d) two of the above (e) all of (a), (b), and (c)

two of the above

In a connected graph with no loops or multiple edges, which of the following inequalities is not correct? (v is the number of vertices, e is the number of edges) (a) e lessthenequal v^2 (b) e greaterthenequal v - 1 (c) v lessthenequal e^2 + 1 (d) v greaterthenequal e/2 (e) all of the above are correct

v greaterthenequal e/2

Which of the following problems is not known to be solvable in linear time? (a) topological sort (b) unweighted shortest path in general graphs (c) weighted shortest path in acyclic graphs (d) weighted shortest path in cyclic graphs (e) all are solvable in linear time

weighted shortest path in cyclic graphs

Which of the following splay tree rotations in effect distinguishes it from rotate-to-root? (a) zig only (b) zig-zag only (c) zig-zig only (d) zig-zig and zig-zag only (e) all of the above

zig-zig only


Kaugnay na mga set ng pag-aaral

Gleim Aviation - Unit 2 - Airplane Instruments, Engines, and Systems

View Set

Chapter 4 - Life Policy Provisions and Options (STUDY)

View Set

Econ 1, Module 28, 34: Monopoly, Monopolistic Competition

View Set

AS Level ICT: Hardware and Software

View Set

Fundamentals Exam 1 set 5 infection control, prevention, and management

View Set

Fitzgerald Practice Questions Endocrine

View Set