





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






CS 1501 Fall 2006 Midterm Exam 2 Name____________________________________ Section (2PM or 6PM) ______________________ You are not allowed to use calculators. You have 50 minutes.
word. To compute the number of codewords k, we need to solve Σi=1k^ I = 106 /2 for k. This sum is about k^2 /2. Thus k is about 10^3. So the number of bits in the output is 10^3 times the number of bits in a codeword, which is not specified in the problem. But a reasonable assumption is say about 16 bits for a codeword. This would about 16000 bits in the output.
Logical integer output: 3 2 1 0 1 3 Letter: D D D D A C Actual ouput file 000111 000110 00001 00000 00001 000111
Your code should run in O(log n) time. Code from the text: itemType PQ::remove() {itemType v = a[1]; a[1] = a[N--]; downheap(1); return v; } void PQ::downheap(int k) { int j; itemType v; v = a[k]; while (k <= N/2) { j = k+k; if (j<N && a[j]<a[j+1]) j++; if (v >= a[j]) break; a[k] = a[j]; k = j; } a[k] = v; }