CPSC 212-301 Test 2B: Computer Science Concepts and Algorithms, Exams of Algorithms and Programming

A computer science test focusing on topics such as sorting algorithms, b-trees, hash tables, and heap structures. The test includes questions on convincing a friend about o(n log n) complexity, inserting values into a b-tree and hash table, performing operations on a leftist minheap and binomial max-queue, and analyzing the output of radixsort and quicksort. It also includes short answer questions.

Typology: Exams

Pre 2010

Uploaded on 07/28/2009

koofers-user-a80
koofers-user-a80 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPSC 212-301 Name: _____________________________
Test #2B October 23, 2006
Honor Pledge:
I pledge that I have neither given nor received unauthorized assistance on this test.
Signed: _______________________ Date: _____________
Closed books. Closed Notes. Calculators OK. 85 points. 60 minutes. Weight of each question in
parentheses. Please use a pencil. For more space, use the back of the sheet.
1. (10) Your friend does not believe that an algorithm that sorts records by comparing keys (sorting by
comparison) can have at best O(N log N) complexity. How would you convince him of this fact?
2. (10) Insert the following values into a B-Tree with M=3 and L=4. Ignore duplicates.
24 29 15 61 27 19 5 7 25 36 4 23 34 72 98 43 16
3. (5) Give a complete and precise definition of a red-black tree.
pf3
pf4

Partial preview of the text

Download CPSC 212-301 Test 2B: Computer Science Concepts and Algorithms and more Exams Algorithms and Programming in PDF only on Docsity!

CPSC 212-301 Name: _____________________________

Test #2B October 23, 2006

Honor Pledge:

I pledge that I have neither given nor received unauthorized assistance on this test.

Signed: _______________________ Date: _____________

Closed books. Closed Notes. Calculators OK. 85 points. 60 minutes. Weight of each question in

parentheses. Please use a pencil. For more space, use the back of the sheet.

1. (10) Your friend does not believe that an algorithm that sorts records by comparing keys (sorting by

comparison) can have at best O(N log N) complexity. How would you convince him of this fact?

2. (10) Insert the following values into a B-Tree with M=3 and L=4. Ignore duplicates.

3. (5) Give a complete and precise definition of a red-black tree.

  1. (10) Insert the following values into a 19 element hash table. Use quadratic probing to handle collisions. Use the hash function: h(x) = x%19. Values: 1 20 39 58 77 2 21 40 59 78 i: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 a: ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
  2. (10) Perform the following operations on an initially empty Leftist minHeaps. Show the final heap. Note that “D” means “delete”.

24 29 15 61 27 19 5 7 D D 4 23 34 D 16

  1. (10) Perform the following operations on an initially empty binomial max -queue. Repeat: Max- Queue. Show the final queue. Note that “D” means “delete”.

24 29 15 61 27 19 5 7 D D 4 23 34 D 16

  1. (5) Consider the following 4-digit numbers. Show the output produced by the first 2 passes of RadixSort on the numbers. After Pass 1 After Pass

1792 _________ ________

4865 _________ ________

2412 _________ ________

2456 _________ ________

8710 _________ ________

2412 _________ ________

4567 _________ ________

1297 _________ ________

1453 _________ ________

2190 _________ ________

4205 _________ ________

  1. (10) Short answers: a) _____ (T/F) A binary heap is a complete tree b) _____ (T/F) In a leftist heap, root’s left child has height greater than the root’s right child. c) Name the four collision handling methods we learned in this class.

    d) Name three O(N log N) sorts
    e) What is another name for diminishing gap sort?