Download presentation

Presentation is loading. Please wait.

Published byJocelyn Preston Modified over 2 years ago

1
Trees 2 and Doubly Linked Lists As you arrive: Please snarf today’s code.

2
3 Topics 1.Some more on height 2.Tree Traversals 3.Doubly Linked Lists 4.Big O of recursive functions

3
Given a tree that’s height-balanced, what is its height? Number of nodes = 7 Height = 3 Number of nodes = 5 Height = 3 A.O(n) B.O(n log n) C.O(log n) D.O(n 2 )

4
What is the maximum amount of time it could take to insert a node in a binary search tree? How about find a node? H = tree height N = # of tree elements 1)O(H) 2)O(N) 3)O(N + H) 4)O(log H) 5)O(H 2 )

5
What is the maximum amount of time it could take to insert a node in a binary search tree? How about find a node? O(tree height)

7
Traversals Preorder (N L R): 7 2 6 5 11 Inorder (L N R): 2 7 5 6 11 Postorder (L R N): 2 5 11 6 7 Read N L R as “first visit node, then visit left subtree, then vision right subtree” Go to “Quizzes/Tests” section of Sakai and find today’s classwork – fill it out

8
Onward! Go to the TreeNodeExample code from Monday’s class Try to write: 1.An iterative version of containsNode that assumes the tree is a binary search tree 2.An iterative version of containsNode that does not assume the tree is a binary search tree (hint: you’ll want a stack or queue)

9
How do we compute the Big O of recursive functions?

10
Solve the problems in RecurrenceRelationProblems.java A. B. C. D. E.

Similar presentations

OK

Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.

Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on natural and artificial satellites Ppt on phonetic transcription ipa Ppt on telephone etiquettes images Ppt on various types of web browsers and their comparative features Ppt on business etiquettes training Ppt on ehv ac dc Ppt on 2 stroke ic engines Ppt on obesity prevention strategies Ppt on mpeg audio compression and decompression algorithms Best ppt on online education