c17s99f - CSc 17 Final Examination Wednesday 12 May 1999 4...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSc 17 Final Examination Wednesday 12 May 1999 4 PM Page 1 !!!!!!!!!!!!!!!SUGGESTED ANSWERS!!!!!!!!!!!!!!!!! 1. (10 pts) Assume class Staque implements an ADT which has the properties of both a stack and a queue. Further assume that Staque has the member functions push(int), enqueue(int), int pop(), int dequeue(), bool full(), and empty(), where the functions push and enqueue have exactly the same effect. For the code below, list the contents of aStaque after each push, pop, enqueue, or dequeue is called. List the entries from left to right, with the latest entry on the right. Staque aStaque(100); //create a Staque with capacity for 100 entries for(int j=5;j<7;j++){ aStaque.push(j); 5 aStaque.push(j+10); 5 15 aStaque.enqueue(aStaque.dequeue()); 15 5 } 15 5 6 while(!aStaque.empty()){ 15 5 6 16 aStaque.pop(); 5 6 16 15 aStaque.dequeue(); 5 6 16 } 6 16 6 <empty> 2. (25 pts) Assume we have the following data structure for building a binary tree: class TNode{ public: int data; TNode *child[2]; }; class Tree{ private: TNode *root; //possibly other stuff. .. public: //other stuff. ... }; Write a member function for Tree called recPrintRange such that the call recPrintRange(root,low,high) displays on the screen all entries in the tree that are greater than the int low and less than the int high. void Tree::recPrintRange(TNode *rt,int low, int high){
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/09/2008 for the course CSE 17 taught by Professor Varies during the Spring '08 term at Lehigh University .

Page1 / 3

c17s99f - CSc 17 Final Examination Wednesday 12 May 1999 4...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online