Computer Science 221 Final Exam Reve
Solve this expression given in postfix form: 20 5 2 */ 10 + 12 3 16 20
12
What is the answer given the postfix notation 3 5 2 + * 2 1 - / 21 18 10 15 12
21
What is the maximum number of elements that can be contained in one node of a 2-4 tree? 3 2 1 4
3
The number of edges in a complete graph with 20 vertices, each with the same degree of 3 is: 15 40 30 60
30
In the DAG shortest path algorithm, you need a minimum priority queue to extract the shortest path. True False
False
Inserting an element into a sorted linked list MPQ is faster than inserting into an unsorted linked list MPQ. True False
False
The Bellman Ford algorithm does not work for graphs with negative-weight edges? True False
False
The SSSP (Single Source Shortest Path) problem is well defined for a graph with negative-weight cycles True False
False
There exists a positive weight cycle on the shortest path from the source to the destination. True False
False
What does it mean to have a strongly connected graph? For any two vertices, there exists a path from one vertex to the other. Each vertex has an in-degree. Each vertex has an out-degree. There are no self loops in the graph.
For any two vertices, there exists a path from one vertex to the other.
Convert this expression to postfix notation: (a*b)-(c+d/e) ab*cd+e/- II. ab*cde/+- III. ab-*cde/+ IV. ab-*cd+e/
II. ab*cde/+-
What is the runtime in terms of big-O notation for the insertion sort algorithm? I. O(n) II. O(log n) III. O(n^2) IV. O(n log n)
III. O(n^2)
Given a binary search tree (BST), what type of traversal would you apply to get the items of the tree in sorted order? Postorder Traversal Preorder Traversal Inorder Traversal
Inorder Traversal
You are running a catalog for library books. You know that the books in the collection are almost in sorted ascending order by title, except one book is in the wrong place. You want the collection to be completely sorted in ascending order. Choose the appropriate sorting method Insertion Sort Merge Sort Radix Sort Heap Sort Counting Sort
Insertion Sort
Which algorithm uses the disjoint-set data structure (with functions Make-Set, Union, and Find-Set) in order to build a minimum spanning tree (MST)? Kruskal's Algorithm Prim's Algorithm Djikstra's Algorithm Bellman-Ford Algorithm Topological Sort
Kruskal's Algorithm
In a binary tree, BFS will return an output equivalent to ___________ and DFS will return an output equivalent to __________. Preorder traversal, postorder traversal Level-order traversal, preorder traversal Level-order traversal, inorder traversal In-order traversal, postorder traversal
Level-order traversal, preorder traversal
Which Minimum Priority Queue implementation determines the minimum stored value in O(1), on average? MPQ based on Sorted List MPQ based on Unsorted List MPQ based on
MPQ based on Sorted List
Which shortest path algorithm will find the correct path when a graph has negative weights? Dijkstra's Algorithm DFS Bellman-Ford Algorithm BFS
Bellman-Ford Algorithm
List sorting algorithms from least to greatest (fastest to slowest) best-case time complexity. (Merge Sort, Bucket sort, Bubble Sort, Selection Sort). Bubble Sort -> Bubble Sort -> Selection Sort -> Merge Sort Bucket Sort -> Bubble Sort -> Merge Sort -> Selection Sort Selection Sort -> Bubble Sort -> Merge Sort -> Bucket Sort Merge Sort -> Bucket Sort -> Selection Sort -> Bubble Sort
Bucket Sort -> Bubble Sort -> Merge Sort -> Selection Sort
Select the most accurate statement from the following statements. i) Chaining method needs less memory than open hashing method. ii) Chaining method needs more memory than open hashing method. iii) Chaining method needs as much memory as the open hashing method.
Chaining method needs more memory than open hashing method.
Which of the following sort algorithms is NOT comparison based? Insertion Sort Counting Sort Bubble Sort Selection Sort
Counting Sort
Which of the following Big O represents the time complexity of building a graph using the adjacent list? O (n) O (|n + m|) O (nm) O (nlog2n)
O (|n + m|)
What is the efficiency of the Depth-First Search on an adjacency list with V vertices and E edges? O(V+E) O(V^2) O(E^2) O(Vlog(E))
O(V+E)
The traversal of a single path on a balanced binary tree from root to leaf is bounded by _____? O(n) O(logn) O(nlogn) O(n^2)
O(logn)
What is the cost of a single insert operation in a Minimum Priority queue implemented using Binary heap? O(n) O(nlogn) O(1) O(logn)
O(logn)
What is the efficiency of BFS and DFS for adjacency list representation? For n is number of edges, and m is number of vertices. O(m^2) O(n+m) O(n^2) O(n-m)
O(n+m)
Using the Master Method, solve the following recurrence relation: T(n) = 4T(n/2) + O(n) O(n) O(nlogn) O(n^2) log_(2) {4} = 2 > 1. T(n) = O(n^(log_(2) {4})) = O(n^2) O(logn)
O(n^2)
What is the efficiency of BFS and DFS for matrix representation? For n is number of edges, and m is number of vertices. O(m^2) O(logn) O(mlogn) O(n^2)
O(n^2)
What is the best case Big-O of merge sort? O(log(n)) O(nlog(n)) O(n) O(1)
O(nlog(n))
What is the Big O for building a heap? O(n) O(logn) O(n^2) O(nlog2(n))
O(nlog2(n))
What is the time complexity for the worst case performance of merge sort? O(nlogn) O(logn) O(n) O(n!)
O(nlogn)
What is the efficiency of the Depth-First Search algorithm with a graph represented as an adjacency list? O(|V| * log(|V|)) O(|V| + |E|) O(|V|^2) O((|V| + |E|) * log(|V|))
O(|V| + |E|)
What is the time complexity of DFS on a graph assuming implementation using adjacency list? O(|V|^2) O(|E|^2) O(|V|+|E|) O(|V| log |E|)
O(|V|+|E|)
What is the efficiency of the Breadth-First Search algorithm with a graph represented as an adjacency matrix? O(|V| * log(|V|)) O(|V| + |E|) O(|V|^2) O((|V| + |E|) * log(|V|))
O(|V|^2)
A stable sorting algorithm: Preserves the order of the first and last elements Ensures the median element = average element Preserves the order of elements with the same key in the sorted output Differentiates between elements of the same key and creates new distinct elements
Preserves the order of elements with the same key in the sorted output
The Breadth-First Search algorithm is commonly implemented with what data structure? Queue Stack BS Tree List
Queue
When traversing a tree using breadth first search (BFS), visited nodes are typically stored in a/an ____? Queue Stack Binary Heap Array
Queue
Which sorting algorithm corresponds to a minimum priority queue implemented based on an unsorted array? Selection sort Insertion sort Heap sort Bubble sort
Selection sort
Which of the following conditions is NOT required for a minimum spanning tree (MST)? Undirected Graph Sum of the edge weights must be negative Tree is Acyclic (no cycles) Tree connects to all vertices in the graph
Sum of the edge weights must be negative
Which recurrence relation represents the worst case for the Quick Sort Algorithm? T(n) = 2T(n / 2) + O(n) T(n) = T(n + 1) + O(n) T(n) = T(n - 1) + O(n) T(n) = T(n - 1) + O(1)
T(n) = T(n - 1) + O(n)
Which of the following is not a difference between the quicksort and mergesort? The ratio of the sizes of the auxiliary subarrays Their worst case time complexities Their best case time complexities The stability of the algorithms
Their best case time complexities
Huffman's algorithm is a technique used for data compression. i) True ii) False
True
Is the selection sort an in-place comparison-based algorithm? True False
True
The efficiency for heapsort is O(nlog2n) for all cases. True False
True
The insertion operation takes up the majority of time in a priority queue based on a sorted array. True False
True
Find the postfix form of the algebraic expression a / b * c / (d + e) ab / c * de + / abc / * de + / a / b c * de + / ab / c * d + e /
ab / c * de + /
Using the queue implementation based on a singly linked list, the enqueue operation___ and the dequeue operation___ inserts at the beginning of the linked list;removes at the beginning of the linked list. inserts at the end of the linked list; removes at the beginning of the linked list. inserts at the end of the linked list;removes at the end of the linked list inserts at the beginning of the linked list; removes at the beginning of the linked list
inserts at the beginning of the linked list; removes at the beginning of the linked list
Which is the correct explanation for the way the stack abstract data type accepts inputs and outputs? first in, last out last in, first out first in, first out last in, last out
last in, first out
What is the space complexity of an adjacency matrix graph G with n vertices and m edges? n^2 m^2 n+m nlog(m)
n^2