l06-trees

l06-trees - CS112 Data Structures Lecture 06 Add Delete...

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

View Full Document Right Arrow Icon
CS112: Slides for Prof. Steinberg ʼ s lecture 1 Lecture 6 CS112: Data Structures CS112: Data Structures Lecture 06 Add / Delete / Search Trees
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS112: Slides for Prof. Steinberg ʼ s lecture 2 Lecture 6 Review: Add / Delete / Search Review: Add / Delete / Search Basic task: Set of data items E.g. “Al”, “Bob”, “Cindy” Operations: Add an item Delete an item Search for an item Goal: minimize worst case O(add + delete + search)
Background image of page 2
CS112: Slides for Prof. Steinberg ʼ s lecture 3 Lecture 6 Unordered Array Unordered Array 0 Carol 1 Anne 2 Bob 3 4 numberOfNames 3 0 Carol 1 Anne 2 Bob 3 Alice 4 numberOfNames 4 Add Alice
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS112: Slides for Prof. Steinberg ʼ s lecture 4 Lecture 6 Unordered Array Unordered Array 0 Carol 1 Anne 2 Bob 3 Alice 4 numberOfNames 4 0 Carol 1 Alice 2 Bob 3 Alice 4 numberOfNames 3 Remove Anne
Background image of page 4
CS112: Slides for Prof. Steinberg ʼ s lecture 5 Lecture 6 Unordered Array Unordered Array Insert O(1) if there’s space Delete O(1) (move last element) Search O(n) where n is size of set Overall O(n)
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS112: Slides for Prof. Steinberg ʼ s lecture 6 Lecture 6 Ordered Array Ordered Array 0 Anne 1 Bob 2 Carol 3 4 numberOfNames 3 Add Alice 0 Alice 1 Anne 2 Bob 3 Carol 4 numberOfNames 4
Background image of page 6
CS112: Slides for Prof. Steinberg ʼ s lecture 7 Lecture 6 Ordered Array Ordered Array Remove Anne 0 Alice 1 Anne 2 Bob 3 Carol 4 numberOfNames 4 0 Alice 1 Bob 2 Carol 3 4 numberOfNames 3
Background image of page 7

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

View Full DocumentRight Arrow Icon
CS112: Slides for Prof. Steinberg ʼ s lecture 8 Lecture 6 Searching an ordered array Searching an ordered array Binary search Binary search requires sorted values each comparison rules out half of the remaining elements O(log(n)) - we will prove this later Find A, find R A D E F G H J M P T ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ 0 1 2 3 4 5 6 7 8 9
Background image of page 8
CS112: Slides for Prof. Steinberg ʼ s lecture 9 Lecture 6 Searching an array Searching an array Performance Performance Search among 1 B illion entries Check 1 million entries per second Sequential search 1 billion operations needed Requires 1000 seconds - about 20 minutes Binary search 30 operations needed Requires 30 microseconds 30 million times faster
Background image of page 9

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

View Full DocumentRight Arrow Icon
CS112: Slides for Prof. Steinberg ʼ s lecture 10 Lecture 6 Searching an array Searching an array Performance Performance Search among 1 M illion entries Check 1 million entries per second Sequential search 1 million operations needed Requires 1 second Binary earch 20 operations needed Requires 20 microseconds 50,000 times faster
Background image of page 10
CS112: Slides for Prof. Steinberg ʼ s lecture 11 Lecture 6 Searching + Insert Searching + Insert Performance Performance 1 billion entries, process 1 million/sec Insert O(n) 1 billion operations needed Requires 1000 seconds - about 20 minutes Binary search O(log n) 30 operations needed Requires 30 microseconds Together: 1000.00003 seconds
Background image of page 11

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

View Full DocumentRight Arrow Icon
CS112: Slides for Prof. Steinberg ʼ s lecture
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 11/01/2011 for the course 198 112 at Rutgers.

Page1 / 55

l06-trees - CS112 Data Structures Lecture 06 Add Delete...

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

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