



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Class: Data Structures and Algorithms; Subject: Computer Science; University: Penn State - Main Campus; Term: Spring 2009;
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Name 1 2 3 4 5 6 7 total
Section
I will not disclose any content of this exam for 44 hours. Signature:
Draw a treap for the following set of keys with priorities (the largest priority should be at the root): key 1 2 3 4 5 6 7 8 9 10 11 priority 5 2 7 0 20 6 2 15 4 1 12
a. Draw a 2-3 tree that results from the tree below if we delete I. M
G
C I
P
N O T U
M
C G
P
N O T U
M
C G N O
P
T U
b. Draw a 2-3 tree that results from the tree below if we insert Q.
M
G
C I
P
N O T U
M
G
C I
P
N O Q T U
M
G
C I
P
N 0 Q
T
U
Given a number array A[n] we can in time O(n) compute array S[n] that allows to answer the the following queries: what is the value of
∑b i=a A[i]?^ (We can have^ S[−1] = 0, S[i] = S[i − 1] + A[i], and the query answer is S[b] − S[a − 1].) Use this to solve the following problem in time O(n^2 ): find i, j such that 0 ≤ i < j < n and the following quantity is maximal:
∑^ j
k=i
A[k]
2 −
∑^ j
k=i
A[k]^2
∑j
Sort given sequence of words alphabetically using Radix sort: ACB, B, CCC, ACA, C, AB, CA, BC, CAC, BCA, CB Show the sequence that results from each round. If your method does not check all words in each round, indicate which words were checked in a round.
Draw the array of chain headers and the chains that form a hash table with hash function h(x) = x mod 11 and which stores the following keys: 3, 5, 9, 12, 14, 17, 21, 33, 42, 50, 55, 62.
0 33 55 1 12 2 3 3 14 4 5 5 6 17 50 7 62 8 9 9 42 10 21