Lecture Slides on Binary Search Tree | COP 3530, Study notes of Data Structures and Algorithms

Material Type: Notes; Class: DATA STRUC/ALGORITHMS; Subject: COMPUTER PROGRAMMING; University: University of Florida; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 09/17/2009

koofers-user-1xm
koofers-user-1xm 🇺🇸

9 documents

1 / 60

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 26
Welcome back!
Binary search trees
15.1-5
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c

Partial preview of the text

Download Lecture Slides on Binary Search Tree | COP 3530 and more Study notes Data Structures and Algorithms in PDF only on Docsity!

  • Lecture
    • • Welcome back! • Binary search trees • 15.1-

Binary Search Trees

• Dictionary Operations:

ƒ^

get(key)

ƒ^

put(key, value)

ƒ^

remove(key)

• Additional operations:

ƒ^

ascend()

ƒ^

get(index) (indexed binary search tree)

ƒ^

remove(index) (indexed binary search tree)

Complexity Of Other Operations

ascend(), get(index), remove(index)^ Data Structure ascend

get andremove

Hash Table

O

(D + n lo

g^

n)

O

(D + n lo

g^

n)

Indexed BST

O(n)

O(n)

IndexedBalanced BST

O(n)

O(log n)

D is number of buckets

Definition Of Binary Search Tree • A binary tree. • Each node has a (key, value) pair. • For every node x, all keys in the leftsubtree of x are smaller than that in x. • For every node x, all keys in the rightsubtree of x are greater than that in x.

The Operation ascend()

Do an inorder traversal. O(n) time.

The Operation get()

Get pair whose key is 8

The Operation get()

8 Get pair whose key is 8

The Operation get()

Get pair whose key is 8

The Operation get()

Complexity is O(height) = O(n), where n isnumber of nodes/elements.

The Operation put()

Put a pair whose key is 35.

The Operation put()

Put a pair whose key is 35.

The Operation put()

Put a pair whose key is 35.

The Operation put()

Put a pair whose key is 7.

The Operation put()

Put a pair whose key is 7.