Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recursion practice. Problem 0 Using recursion (and no arrays), write the code to read in a series of numbers (until EOF) and then print them backwards.

Similar presentations


Presentation on theme: "Recursion practice. Problem 0 Using recursion (and no arrays), write the code to read in a series of numbers (until EOF) and then print them backwards."— Presentation transcript:

1 Recursion practice

2 Problem 0 Using recursion (and no arrays), write the code to read in a series of numbers (until EOF) and then print them backwards.

3 Problem 1 Write is leftist which determines if every node in a tree has a right child which is never of greater height that the left child. a a b c d e a b c d e Leftist

4 Problem 2 Write the code to perform BST deletion

5 Problem 3 Write the code to insert a node into a binary search tree that has parent pointers.

6 Problem 4 Find the largest element value in a binary tree (which is not a BST)

7 Problem 5 Write the pseudo code to list all possible rearrangements of the letters of a provided word. void printAnagrams(string prefix, string word)

8 Reading recursion int doit(int x) { if (x == 0) return 0; else { cout << x; return doit(x - 1); }

9 int doit2(int x, int y) { if y==0 return 1; return (x * doit2(x, y – 1)); }

10 void doit3(tree_node *p) { if (p != NULL) { doit3(p->left); doit3(p->right); cout data << endl; }


Download ppt "Recursion practice. Problem 0 Using recursion (and no arrays), write the code to read in a series of numbers (until EOF) and then print them backwards."

Similar presentations


Ads by Google