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

Topic 15 The Binary Search Tree ADT. 11-2 Binary Search Tree A binary search tree (BST) is a binary tree with an ordering property of its elements, such.

Topic 15 The Binary Search Tree ADT. 11-2 Binary Search Tree A binary search tree (BST) is a binary tree with an ordering property of its elements, such.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google