c17f98f - CSc 17 Page 1 Final Examination Monday 14...

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

View Full Document Right Arrow Icon
Final Examination Monday 14 December 1998 Page 1 1. ( pts) Assume the declarations of class biNode and of rt below. Write a function "zero" such that the call "zero(rt)" stores a 0 in each leaf of the tree whose root is rt. The function assumes that rt is indeed the root of a properly defined tree. That is, rt either points to NULL or to a biNode, and the children of each biNode in the tree are either NULL or a biNode. class biNode{ public: int key; biNode *left,*right; } biNode *rt; ------------- void zero(biNode *rt){ if(rt!=NULL) rt->key=0; else { zero(rt->left); zero(rt->right); } } 2. ( pts) Write a function DIGITS which makes a copy of a file of text which is identical to the original file, except that any line which has at least one digit has an asterisk (*) appended to it. So, for example, if the file consists of 7 lines of text for this question, the new file would be identical, except that the first and fourth lines would have an asterisk at the end. Assume the call is DIGITS(in,out) where we have ofstream out; ifstream in; char ch; bool foundDigit; in.get(ch); while(!in.eof()){ foundDigit=false; foundDigit=true; out.put(ch); in.get(ch); } if(foundDigit) out.put('*'); out.put('\n'); in.get(ch); } } 3. ( pts) Suppose we have the following prototypes and declarations. int f(int i, int j);
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.

Page1 / 4

c17f98f - CSc 17 Page 1 Final Examination Monday 14...

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