Notes 13 - Week 13: Binary Search Trees Some of the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Week 13: Binary Search Trees Some of the material covered is contained in Chapter 25 (about bst) and the rest is in Chapter 27 about bst implementations. Definitions: A binary search tree is an ordered binary tree such that for every node all data is less on the left subtree all data is greater on the right subtree No duplicates allowed in some versions of BST’s. Task 1: Determine if the binary tree is a bst. 50 / \ 10 60 / \ / \ 5 40 30 70 Answer : No because 30 is a right child of 50. Now do #14 and 15 on page 660 and check your answers in the appendix. Note: The inorder traversal is an ascending sequence of the data! So another way to sort data would be to create a bst and then do the inorder traversal. Searching a bst is faster as there is no need to backtrack however the worst case has a big oh of n due to shape of the worst case is a linked list. But a complete bst has a worst case search of O(log n) Task 2: Read section 27.42 on page 726 and review figure 27-14 on page 727
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/23/2012 for the course CS 111C taught by Professor Metzler during the Spring '11 term at City College of San Francisco.

Page1 / 2

Notes 13 - Week 13: Binary Search Trees Some of the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online