recursion practice
Download
Skip this Video
Download Presentation
Recursion practice

Loading in 2 Seconds...

play fullscreen
1 / 10

Recursion practice - PowerPoint PPT Presentation


  • 77 Views
  • Uploaded on

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. Problem 1.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Recursion practice' - ginny


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
problem 0
Problem 0
  • Using recursion (and no arrays), write the code to read in a series of numbers (until EOF) and then print them backwards.
problem 1
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

a

c

b

c

b

e

d

e

d

Leftist

Leftist

problem 2
Problem 2
  • Write the code to perform BST deletion
problem 3
Problem 3
  • Write the code to insert a node into a binary search tree that has parent pointers.
problem 4
Problem 4
  • Find the largest element value in a binary tree (which is not a BST)
problem 5
Problem 5
  • Write the pseudo code to list all possible rearrangements of the letters of a provided word.

void printAnagrams(string prefix, string word)

reading recursion
Reading recursion

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

slide9

int doit2(int x, int y)

{ if y==0 return 1;

return (x * doit2(x, y – 1));

}

slide10

void doit3(tree_node *p)

{ if (p != NULL) {

doit3(p->left);

doit3(p->right);

cout << p->data << endl;

} }

ad