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

Info icon This 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.
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern