ECS 60 Practice Final: Data Structures and Algorithms - Prof. Sean S. Davis, Exams of Computer Science

A practice final exam for a computer science course focusing on data structures and algorithms. The exam covers various topics including class programs, trees (avl, splay, b-trees, skip lists), hash tables (linear probing, quadratic probing, double hashing, extendible hashes), priority queues (binary heap, leftist heap, skew heap, binomial queues), sorting algorithms (shellsort, heapsort, quicksort, radix sort), and graph theory. Students are required to show the intermediate steps and results of operations for each problem.

Typology: Exams

Pre 2010

Uploaded on 07/30/2009

koofers-user-q8s
koofers-user-q8s 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECS 60 Practice Final
1. Class program (15 points)
This question will attempt to determine whether you wrote the code for p5. There is no need for you to see sample
questions if you actually participated in writing the code.
2. Trees (25 points) Possible “trees” are AVL trees, splay trees, B-Trees, and skip lists. Show the result of accessing
node 14 in the following splay tree. To receive partial credit you should show the intermediate tree after the zig-zig
3
2 20
6 32
5 10
9 14
12 16
3. Hash (25 points) Possible areas explored are linear probing, quadratic probing, double hashing, and extendible
hashes. Assuming linear probing with a hash function of key mod TableSize, an initial TableSize of 3, and rehashing
when the load factor exceeds 0.5, show the hash table after each of the operations. Also fill-in the TableSize column.
Operation Table
Size
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
insert 21 3
insert 22
insert 4
insert 0
insert 1
delete 0
insert 34
5 Priority Queues (25 points) Possible priority queues are binary heap, leftist heap, skew heap, and binomial queues.
For each of the following binary heaps, show the state of heap after operation specified.
Insert(20)
8
28 64
37 59 87 69
43 76 66
DeleteMin()
8
28 64
37 59 87 69
43 76 66
6 Sorting I (25 points) Possible sorts are shellsort, heapsort, quicksort, and radix sort. For Hibbard's increments of
1,3,7, …, 2k -1, show the state of the array during a Shellsort. Fill in the increment for each row. There may be
more rows than needed.
pf2

Partial preview of the text

Download ECS 60 Practice Final: Data Structures and Algorithms - Prof. Sean S. Davis and more Exams Computer Science in PDF only on Docsity!

ECS 60 Practice Final

  1. Class program (15 points) This question will attempt to determine whether you wrote the code for p5. There is no need for you to see sample questions if you actually participated in writing the code.
  2. Trees (25 points) Possible “trees” are AVL trees, splay trees, B-Trees, and skip lists. Show the result of accessing node 14 in the following splay tree. To receive partial credit you should show the intermediate tree after the zig-zig 3 2 20 6 32 5 10 9 14 12 16
  3. Hash (25 points) Possible areas explored are linear probing, quadratic probing, double hashing, and extendible hashes. Assuming linear probing with a hash function of key mod TableSize, an initial TableSize of 3, and rehashing when the load factor exceeds 0.5, show the hash table after each of the operations. Also fill-in the TableSize column. Operation Table Size

insert 21 3 insert 22 insert 4 insert 0 insert 1 delete 0 insert 34 5 Priority Queues (25 points) Possible priority queues are binary heap, leftist heap, skew heap, and binomial queues. For each of the following binary heaps, show the state of heap after operation specified. Insert(20) 8 28 64 37 59 87 69 43 76 66 DeleteMin() 8 28 64 37 59 87 69 43 76 66 6 Sorting I (25 points) Possible sorts are shellsort, heapsort, quicksort, and radix sort. For Hibbard's increments of 1,3,7, …, 2k^ -1, show the state of the array during a Shellsort. Fill in the increment for each row. There may be more rows than needed.

Increment 9 18 4 83 6 59 12 22 3 35 67 16 7 44 1 7 Sorting II (25 points) QuickSort. Sort the following array using a Median of Three and a cutoff of three (series of three will just use insertion sort with no pivot). Place the pivot in the next to last position and the largest of the three in the to last position. Do not find the largest element and do not put it at then end. You may use rows for intermediate steps, but circle each pivot when it is first placed in its correct (“golden”) position. Intermediate steps will not be graded. Only those lines with new circled pivots will be graded. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 5A 9 5B 4 11 8 12 7 10 13 6 1 5C 3 2 8 Graph I(25 points) There will be three graph problems. See the practice midterm for examples of all the possible formats. 9 Graph II (25 points) 10 Graph III(25 points) 11 ADT design (75 points) Please note that this problem does not reflect reality. It is just an ECS 10 problem placed within a familiar context. Pacific Bell has a huge network of wires with which to connect each phone call within the 530 area code. We are only concerned with calls between different cities within the 530 area code. For each call, the routing program has three tasks: 1) it must find an available route from the source city to the destination city; 2) it must update its data structures so that they accurately reflect assigned paths; and 3) when the call is done, the program should update its data structures so that route is now freed for other calls. Describe and justify your choices of data structure(s) and routine(s) that you would use to implement the routing program. Be sure to describe your three operations, including their time complexity. You may assume the following:  There are 300 cities in the 530 area code. Each city has one central location for all its routing switches. There are never more than 1,000,000 intercity calls at one time.  The first three digits of a phone number are called a prefix. Phones with same prefixes are all in the same city.  A "trunk line" connects one city to exactly one other city. Each trunk line can handle 100,000 calls at a time. The trunk lines rarely reach capacity. Each city is directly connected through trunk lines to five other cities.  There is one computer that determines the route for all calls. The computer has 256M of RAM. It need not determine the specific wire to use for a connection; it need only determine the route.