0% found this document useful (0 votes)
42 views1 page

Print Clearly !!: Quiz #5 CS 153

The document contains a quiz with multiple choice and coding questions about queues and recursion. It tests knowledge of queue implementation using arrays versus linked lists and how to recursively calculate powers of two. The questions cover queue operations like enqueue, dequeue and how they interact with the underlying data structure.

Uploaded by

dodoman666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views1 page

Print Clearly !!: Quiz #5 CS 153

The document contains a quiz with multiple choice and coding questions about queues and recursion. It tests knowledge of queue implementation using arrays versus linked lists and how to recursively calculate powers of two. The questions cover queue operations like enqueue, dequeue and how they interact with the underlying data structure.

Uploaded by

dodoman666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

QUIZ #5

CS 153
name _______________________
print clearly !!
Show All Work
Be Neat (I have little tolerance for slppiness slupiness sloppiness )
Be Literate
25 pts.
1. The circular array implementation of a queue (not a priority queue) that was discussed in class requires what worstcase running time for the pop (or dequeue) operation? (Assume n is the number of items in the queue.)
[5]
a. O(n2)
b. O(n)
c. O(log n)
d. O(1)
*
2. If a queue (not a priority queue) is implemented with a pointer-based linked or (doubly linked) list, with the push
operation done with insertTailNode, then the pop (or dequeue) operation should be done by calling:
[5]
e. removeHeadNode
*
f. removeTailNode
g. the queue destructor
h. getTailPtr
i. setTailPtr
j. another student who has already passed cs 153 with an A
3. Suppose that a QUEUE is implemented with a circular array of size 3. Show the contents of the queues data array
and the value of the integer front member variable after the code below is executed.
[5]
QUEUE q;
q.enqueue(20);
q.enqueue(30);
q.enqueue(40);
q.dequeue( );
q.enqueue(60);
q[0] is 60

q[1] is 30

q[2] is 40

and front would indicate q[1].

4. Write C++ code for a recursive function (NO LOOPS!) which does the following: Given an integer parameter n (n 0),
return 2 n. You may not use the C++ pow function.
[10]

int F(const int n)


{
assert(n >= 0);
if (n == 0)
return(1);
else
return(2 * F(n 1));
}

// good practice, but not required in solution

You might also like