l please get a complete set (brown, green, red and yellow) of colored paper from the front

27
l • Please get a complete set (brown, green, red and yellow) of colored paper from the front.

Upload: garey-cole

Post on 03-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

l• Please get a complete set

(brown, green, red and yellow) of colored paper from the front.

Page 2: 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

Page 3: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

Topics of Emphasis (not exhaustive)

Java    Public Private     Pass by Value / Class Encap     Overriding     Iterator     Inheritance     Wrapper      Exceptions     Commenting    Testing    Recusion / Iteration

Page 4: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 5: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

Topics of Emphasis (not exhaustive)

Sorting / Algorithms    Dijkstras     Topological Sort

    Binary Search

    Bubble    Insert    Selection    Merge    Quick

Page 6: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 7: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 8: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 9: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 10: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 11: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 12: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 13: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 14: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 15: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 16: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 17: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 18: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 19: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 20: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 21: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 22: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 23: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 24: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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?

Page 25: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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

Page 26: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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.

Page 27: L Please get a complete set (brown, green, red and yellow) of colored paper from the front

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