l • Please get a complete set (brown, green, red and yellow) of colored paper from the front.
Jan 03, 2016
l• Please get a complete set
(brown, green, red and yellow) of colored paper from the front.
CS 61BL Final Review
Data StructuresColleen Lewis, Kaushik Iyer, Jonathan
Kotker, David Zeng, George Wang
Topics of Emphasis (not exhaustive)
Java Public Private Pass by Value / Class Encap Overriding Iterator Inheritance Wrapper Exceptions Commenting Testing Recusion / Iteration
Topics of Emphasis (not exhaustive)
Data Structures Hash Tables Array / Linked List Destructive / Non-Destructive Graphs List/Matrix Priority Queue / Heap Bottom Up Heap Stack Queues Trees BST AVLTree
Topics of Emphasis (not exhaustive)
Sorting / Algorithms Dijkstras Topological Sort
Binary Search
Bubble Insert Selection Merge Quick
How long does it take to determine if an undirected graph contains a vertex that is connected to no other vertices if you use an adjacency matrix?
Option A: V+E
Option B: V^2
Option C: VE
Option D: V
How long does it take to determine if an undirected graph contains a vertex that is connected to no other vertices if you use an adjacency matrix?
Option A: V+E
Option B: V^2
Option C: VE
Option D: V
How long does it take to determine if an undirected graph contains a vertex that is connected to no other vertices if you use an adjacency LIST?
Option A: V+E
Option B: V^2
Option C: VE
Option D: V
How long does it take to determine if an undirected graph contains a vertex that is connected to no other vertices if you use an adjacency LIST?
Option A: V+E
Option B: V^2
Option C: VE
Option D: V
What is the Topological Sort?
Option A: B E A C D
Option B: B A E C D
Option C: B A C E D
Option D: Other
What is the Topological Sort?
Option A: B E A C D
Option B: B A E C D
Option C: B A C E D
Option D: Other
What is the Dijkstra’s order it visits nodes, and distances from B?
Option A: BADCE
Option B: BDACE
Option C: BEACD
Option D: BACDE
What is the Dijkstra’s order it visits nodes, and distances from B?
Option A: BADCE
Option B: BDACE
Option C: BEACD
Option D: BACDE
Apply the Radix sort algorithm on the following list of English words: COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, BIG, TEA, NOW, FOX.
Show the following in Order
Option A: COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, BIG, TEA, NOW, FOXOption B: SEA TEA MOB TAB DOG RUG DIG BIG BAR EAR TAR COW ROW NOW BOX FOX
Option C: TAB BAR EAR TAR TEA SEA BIG DIG MOB DOG COW ROW NOW BOX FOX RUG
Option D: BAR BIG BOX COW DIG DOG EAR FOX MOB NOW ROW RUG SEA TAB TAR TEA
Apply the Radix sort algorithm on the following list of English words: COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, BIG, TEA, NOW, FOX.
Show the following in Order: ABCD
Option A: COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, BIG, TEA, NOW, FOXOption B: SEA TEA MOB TAB DOG RUG DIG BIG BAR EAR TAR COW ROW NOW BOX FOX
Option C: TAB BAR EAR TAR TEA SEA BIG DIG MOB DOG COW ROW NOW BOX FOX RUG
Option D: BAR BIG BOX COW DIG DOG EAR FOX MOB NOW ROW RUG SEA TAB TAR TEA
After a few iterations of some sort, this is what we have so far. Which?
123657984
Option A: Insertion Sort / Selection
Option B: Quick Sort
Option C: Merge Sort
Option D: Heap Sort
After a few iterations of some sort, this is what we have so far. Which?
123657984
Option A: Insertion Sort / Selection
Option B: Quick Sort
Option C: Merge Sort
Option D: Heap Sort
After a few iterations of some sort, this is what we have so far. Which?
278913568
Option A: Insertion Sort / Selection
Option B: Quick Sort
Option C: Merge Sort
Option D: Heap Sort
After a few iterations of some sort, this is what we have so far. Which?
278913568
Option A: Insertion Sort / Selection
Option B: Quick Sort
Option C: Merge Sort
Option D: Heap Sort
After a few iterations of some sort, this is what we have so far. Which?
531268789
Option A: Insertion Sort / Selection
Option B: Quick Sort
Option C: Merge Sort
Option D: Heap Sort
After a few iterations of some sort, this is what we have so far. Which?
278913568
Option A: Insertion Sort / Selection
Option B: Quick Sort
Option C: Merge Sort
Option D: Heap Sort
After a few iterations of some sort, this is what we have so far. Which?
531268789
Option A: Insertion Sort / Selection
Option B: Quick Sort
Option C: Merge Sort
Option D: Heap Sort
After a few iterations of some sort, this is what we have so far. Which?
278913568
Option A: Insertion Sort / Selection
Option B: Quick Sort
Option C: Merge Sort
Option D: Heap Sort
An undirected graph contains a "cycle" (i.e., loop) if there are two different simple paths by which we can get from one vertex to another. Using your favorite graph traversal algorithm, how can we tell if an undirected graph contains a cycle?
For the following list of numbers, run the following sorting algorithms:
6 5 4 2 8 3 1 0 9 7
As an example, here’s Selection Sort:6 5 4 2 8 3 1 0 7 96 5 4 2 3 1 0 7 8 95 4 2 3 1 0 6 7 8 94 2 3 1 0 5 6 7 8 92 3 1 0 4 5 6 7 8 92 1 0 3 4 5 6 7 8 91 0 2 3 4 5 6 7 8 90 1 2 3 4 5 6 7 8 9
RadixHeap SortQuick Sort (Pick a random pivot)Merge SortInsertion Sort
Recall that an undirected graph is "connected" if there is a path from any vertex to any other vertex. If an undirected graph is not connected, it has multiple connected components. A connected component" consists of all the vertices reachable from a given vertex, and the edges incident on those vertices. Suggest an algorithm based on DFS (possibly multiple invocations of DFS) that counts the number of connected components in a graph.
Code a ‘contains’ method for a Priority Queue implemented as a MinHeap that requires the fewest number of comparisons possible. We don’t mean asymptotically, we mean the absolute fewest comparisons possible.
For sake of simplicity, assume the array-based implementation of minHeap, where the first element occurs at index 1.
Assume it is represented as the following:int[] heap = new int[n]; //n is the size of the heap