Download presentation

Presentation is loading. Please wait.

Published byGloria Kinn Modified about 1 year ago

1
CS208 Coursework 2 Neil Ghani Mark Dukes Handin: Friday 11 March, 12pm, Departmental Office

2
Question 1: Write an algorithm that takes a tree as input and returns the largest element stored in the tree Question 2: Write an algorithm that counts the number of pieces of data stored in a tree Trees

3
More Trees Question 3: Write an algorithm that takes as input a number n and a tree and prints out all data stored at depth n. So if t is the tree 6 / \ 5 7 / \ 9 12

4
Q3 Continued … then printAt 0 t = 6 printAt 1 t = 5, 7 printAt 2 t = 9, 12 Hint: Use recursion on the number as well as the tree. Look at cutAt in the lecture slides.

5
BSTs Q4: Give all the BSTs which store the numbers 1, 2, 3, 4, 5 Q5: Look at the tree given in Q3. What are the results of printing out the data stored in that tree using i) preorder traversal; ii) inorder traversal; and iii) post order traversal

6
Even More Trees Q6 Define an algorithm which takes two trees as input and returns the depth at which they first differ

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google