l • Please get a complete set colored paper from the front.

advertisement
• Please get a complete set
(brown, green, red andl yellow) of
colored paper from the front.
CS 61BL Final Review
Data Structures
Colleen 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:
BEACD
Option B:
BAECD
Option C:
BACED
Option D:
Other
What is the Topological Sort?
Option A:
BEACD
Option B:
BAECD
Option C:
BACED
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, FOX
Option 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, FOX
Option 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:
6542831097
As an example, here’s Selection Sort:
6542831079
6542310789
5423106789
4231056789
2310456789
2103456789
1023456789
0123456789
Radix
Heap Sort
Quick Sort (Pick a random pivot)
Merge Sort
Insertion 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
Download