CS : Data Structures

Size: px
Start display at page:

Download "CS : Data Structures"

Transcription

1 CS : Data Structures Michael Schatz Nov 7, 2016 Lecture 28: HashTables

2 Assignment 8: Due Thursday Nov 10pm Remember: javac Xlint:all & checkstyle *.java & JUnit Solutions should be independently written!

3 Part 1: AVL Trees

4 Binary Search Tree k <k >k A BST is a binary tree with a special ordering property: If a node has value k, then the left child (and its descendants) will have values smaller than k; and the right child (and its descendants) will have values greater than k

5 Tree Rotations right-rotation(b) left-rotation(a) B A A B <A <B >A <B >A >B <A <B >A <B >A >B Note: Rotating a BST maintains the BST condition! Green < A < Brown < B < Purple

6 Complete Example Insert these values: ins(5) ins(2) 4 4 \ 5 ins(7) 4 \ 5 \ 7 5 / \ 4 7 l(4) ins(1) 5 / \ 4 7 / 2 5 / \ 4 7 / 2 / 1 Note: AVL Violations are fixed bottom up r(4) 5 / \ 2 7 / \ 1 4 ins(3) l(2) 5 / \ 2 7 / \ 1 4 / 3 5 / \ 4 7 / 2 / \ / \ 2 5 / \ \ r(5)

7 Removing 6 / \ 3 8 / \ / \ / \ / \ / \ \ / \ / \ 3 9 / 1 or 9 / 3 / \ 1 4 Remove leaf is easy Remove with only one child Is easy Remove Internal Node: Swap with predecessor /successor Remove from AVL just like removing from regular BST: Find successor Swap with that element, Remove the node that you just swapped. Make sure to update the height fields, and rebalance if necessary

8 Implementation Notes Rotations can be applied in constant time! Inserting a node into an AVL tree requires O(lg n) time and guarantees O(lg(n)) height Track the height of each node as a separate field The alternative is to track when the tree is lopsided, but just as hard and more error prone Don t recompute the heights from scratch, it is easy to compute but requires O(n) time! Since we are guaranteeing the tree will have height lg(n), just use an integer Only update the affected nodes Check out Appendix B for some very useful tips on hacking AVL trees!

9 AVL Tree Balance By construction, an AVL tree can never become too unbalanced AVL condition ensures left and right children differ by at most 1 But they arent necessarily full n=1 n=2 n=3 n=4 n=5 n=6 n=7

10 Sparse AVL Trees How many nodes are in the sparsest AVL tree of height h Sparse means fewest nodes with height h Does it still include an exponential number of nodes? S 1 S 2 S 3 S 4 S 5 h=1 n=1 h=2 n=2 h=3 n=4 h=4 n=7 h=5 n=12

11 Sparse AVL Trees How many nodes are in the sparsest AVL tree of height h Sparse means fewest nodes with height h Does it still include an exponential number of nodes? S 1 S 2 S 3 S 4 S 5 h=1 n=1 h=2 n=2 h=3 n=4 h=4 n=7 h=5 n=12 S 1 = 1 S 2 = 2 S 3 = S 2 + S S 4 = S 3 + S S 5 = S 4 + S S h = S h-1 + S h-2 + 1

12 Fibonacci Sequence public static int fib(int n) { if (n <= 1) { return 1; } return fib(n-1) + fib(n-2); } F(6) f(5) f(4) f(4) f(3) f(3) f(2) f(3) f(2) f(2) f(1) f(2) f(1) f(1) f(0) f(2) f(1) f(1) f(0) f(1) f(0) f(1) f(0) f(1) f(0)

13 Nodes in an AVL Tree How many nodes are in the sparsest AVL tree of height h Sparse means fewest nodes with height h Does it still include an exponential number of nodes? S(h) = F(h + 3) 1 Fibonacci grows exponentially at φ n AVL Trees grow exponentially at φ n -1 Therefore the height of any AVL tree is O(lg n)

14 Part 2: Treaps

15 BSTs versus Heaps p k p <k >k p p BST All keys in left subtree of k are < k, all keys in right are >k Tricky to balance, but fast to find Heap All children of the node with priority p have priority p Easy to balance, but hard to find (except min/max)

16 BSTs versus Heaps p k p <k >k p p BST All keys in left subtree of k are < k, all keys in right are >k Tricky to balance, but fast to find Heap All children of the node with priority p have priority p Easy to balance, but hard to find (except min/max)

17 Treap k/p <k /p >k /p A treap is a binary search tree where the nodes have both user specified keys (k) and internally assigned priorities (p). When inserting, use standard BST insertion algorithm, but then use rotations to iteratively move up the node while it has lower priority than its parent (analogous to a heap, but with rotations)

18 Treap Reflections Insert the following pairs: 7/1, 2/2, 1/3, 8/4, 3/5, 5/6, 4/7 7/1 / \ Since the priorities are in sorted order, becomes a standard BST and may have O(n) height 2/2 8/4 / \ 1/3 3/5 \ 5/6 / 4/7 Insert the following pairs: 7/3, 2/0, 1/7, 8/2, 3/9, 5/1, 4/7 With a standard BST, for 2 to be root it would have to be the first key inserted, and 5 would have to proceed all the other keys except 1, It is as if we saw the sequence: 2,5,8,7,1,4,3 Note priorities in sorted order: 2/0, 5/1, 8/2/, 7/3, 1/7, 4/7, 3/9 2/0 / \ 1/7 5/1 / \ 4/7 8/2 / / 3/9 7/3

19 What priorities should we assign to maintain a balanced tree? Math.random() Using random priorities essentially shuffles the input data (which might have bad linear height) into a random permutation that we expect to have O(log n) height J It is possible that we could randomly shuffle into a poor tree configuration, but that is extremely rare. In most practical applications, a treap will perform just fine, and will often outperform an AVL tree that guarantees O(log n) height but has higher constants

20 Random Tree Height ## Trying all permutations of 14 distinct keys numtrees: 87,178,291,200 average height: 6.63 maxheights[0]: % maxheights[1]: % maxheights[2]: % maxheights[3]: % maxheights[4]: % maxheights[5]: % maxheights[6]: % maxheights[7]: % maxheights[8]: % maxheights[9]: % maxheights[10]: % maxheights[11]: % maxheights[12]: % maxheights[13]: % maxheights[14]: %

21 Random Tree Height ## Trying all permutations of 15 distinct keys $ tail -f heights.15.log tree[ ]: maxheight: 6 tree[ ]: maxheight: 7 tree[ ]: maxheight: 7 tree[ ]: maxheight: 7 tree[ ]: maxheight: 7 tree[ ]: maxheight: 7 tree[ ]: maxheight: 7 tree[ ]: maxheight: 7 tree[ ]: maxheight: 9 tree[ ]: maxheight: 7 tree[ ]: maxheight: 7 tree[ ]: maxheight: 7 tree[ ]: maxheight: 7 tree[ ]: maxheight: 9 tree[ ]: maxheight: 8 tree[ ]: maxheight: 7

22 Self Balancing Trees Understanding the distinction between different kinds of balanced search trees: AVL trees guarantee worst case O(log n) operations by carefully accounting for the tree height splay trees guarantee amortized O(log n) operations by periodically applying a certain set of rotations (see lecture notes) treaps guarantee expected O(log n) operations by selecting a random permutation of the input data So if you have to play it safe and don t trust your random numbers, AVL trees are the way to go. If you can live with the occasional O(n) operation every now and then and you still don t trust your random numbers, splay trees are the way to go. And if you trust your random numbers, treaps are the way to go.

23 Part 3: Hash Tables

24 Maps aka dictionaries aka associative arrays Mike -> Malone 323 Peter -> Malone 223 Joanne -> Malone 225 Zack -> Malone 160 suite Debbie -> Malone 160 suite Yair -> Malone 160 suite Ron -> Garland 242 Key (of Type K) -> Value (of Type V) Note you can have multiple keys with the same value, But not okay to have one key map to more than 1 value

25 Maps, Sets, and Arrays Sets as Map<T, Boolean> Array as Map<Integer, T> Mike Peter Joanne Zack Debbie Yair Ron -> True -> True -> True -> True -> True -> True -> True 0 -> Mike 1 -> Peter 2 -> Joanne 3 -> Zack 4 -> Debbie 5 -> Yair 6 -> Ron Maps are extremely flexible and powerful, and therefore are extremely widely used Built into many common languages: Awk, Python, Perl, JavaScript Could we do everything in O(lg n) time or faster? => Balanced Search Trees

26 Maps, Sets, and Arrays Sets as Map<T, Boolean> Array as Map<Integer, T> Mike Peter Joanne Zack Debbie Yair Ron -> True -> True -> True -> True -> True -> True -> True 0 -> Mike 1 -> Peter 2 -> Joanne 3 -> Zack 4 -> Debbie 5 -> Yair 6 -> Ron Maps are extremely flexible and powerful, and therefore are extremely widely used Built into many common languages: Awk, Python, Perl, JavaScript Could we do everything in O(lg n) time or faster? => Balanced Search Trees

27 ADT: Arrays n-3 n-2 n-1 a: t t t t t t get(2) put(n-2, X) Fixed length data structure Constant time get() and put() methods Definitely needs to be generic J

28 Hashing Array[13] = 10; Array[42] = 15 O(1) Array[ Mike ] = 10; Array[ Peter ] = 15 BST:O(lg n) -> Hash:O(1) Hash Function enables: Map<K, V> -> Map<Integer, V> -> Array<V> h(): K -> Integer for any possible key K h() should distribute the keys uniformly over all integers if k 1 and k 2 are close, h(k 1 ) and h(k 2 ) should be far apart Typically want to return a small integer, so that we can use it as an index into an array An array with 4B cells in not very practical if we only expect a few thousand to a few million entries How do we restrict an arbitrary integer x into a value up to some maximum value n? 0 <= x % n < n Compression function: c(i) = abs(i) % length(a) Transforms from a large range of integers to a small range (to store in array a)

29 Collisions Collisions occur when 2 different keys get mapped to the same value Within the hash function h(): Rare, the probability of 2 keys hashing to the same value is 1/4B. Within the compression function c(): Common, 4B integers -> n values Example: Hashing integers into an array with 8 cells h(i) = i c(i) = i % 8 a Peter insert(1, Peter ): c(h(1)) = c(1) = 1

30 Collisions Collisions occur when 2 different keys get mapped to the same value Within the hash function h(): Rare, the probability of 2 keys hashing to the same value is 1/4B. Within the compression function c(): Common, 4B integers -> n values Example: Hashing integers into an array with 8 cells h(i) = i c(i) = i % 8 a Peter Paul Insert(20, Paul ): c(h(4)) = c(4) = 4

31 Collisions Collisions occur when 2 different keys get mapped to the same value Within the hash function h(): Rare, the probability of 2 keys hashing to the same value is 1/4B. Within the compression function c(): Common, 4B integers -> n values Example: Hashing integers into an array with 8 cells h(i) = i c(i) = i % 8 a Peter Paul Mary insert(15, Mary ): c(h(15)) = c(15) = 7

32 Collisions Collisions occur when 2 different keys get mapped to the same value Within the hash function h(): Rare, the probability of 2 keys hashing to the same value is 1/4B. Within the compression function c(): Common, 4B integers -> n values Example: Hashing integers into an array with 8 cells h(i) = i c(i) = i % 8 a Peter Paul Mary get(15): get(c(h(15))) = get(c(15)) = get(7) => Mary J

33 Collisions Collisions occur when 2 different keys get mapped to the same value Within the hash function h(): Rare, the probability of 2 keys hashing to the same value is 1/4B. Within the compression function c(): Common, 4B integers -> n values Example: Hashing integers into an array with 8 cells h(i) = i c(i) = i % 8 a Peter Paul Mary has(4): has(c(h(4)) = has(c(4)) = has(4) => Paul L

34 Collisions Collisions occur when 2 different keys get mapped to the same value Within the hash function h(): Rare, the probability of 2 keys hashing to the same value is 1/4B. Within the compression function c(): Common, 4B integers -> n values Example: Hashing integers into an array with 8 cells h(i) = i c(i) = i % 8 a Peter Paul Mary Beverly insert(4, Beverly ): c(h(4)) = c(4) = 4 L

35 Collisions Collisions occur when 2 different keys get mapped to the same value Within the hash function h(): Rare, the probability of 2 keys hashing to the same value is 1/4B. Within the compression function c(): Common, 4B integers -> n values Example: Hashing integers into an array with 8 cells h(i) = i c(i) = i % 8 a Peter Paul Mary Two problems caused by collisions: False positives: How do we know the key is the one we want? Collision Resolution: What do we do when 2 keys map to same location?

36 Collisions Collisions occur when 2 different keys get mapped to the same value Within the hash function h(): Rare, the probability of 2 keys hashing to the same value is 1/4B. Within the compression function c(): Common, 4B integers -> n values Example: Hashing integers into an array with 8 cells h(i) = i c(i) = i % 8 a (1, Peter ) (20, Paul ) (15, Mary ) Two problems caused by collisions: False positives: How do we know the key is the one we want? Collision Resolution: What do we do when 2 keys map to same location?

37 Separate chaining Use Array<List<V>> instead of an Array<V> to store the entries a (1, Peter ) (20, Paul ) (15, Mary ) o o o insert(4, Beverly ): c(h(4)) = c(4) = 4

38 Separate chaining Use Array<List<V>> instead of an Array<V> to store the entries a (1, Peter ) (20, Paul ) (15, Mary ) o (4, Beverly ) o o insert(4, Beverly ): c(h(4)) = c(4) = 4

39 Separate chaining Use Array<List<V>> instead of an Array<V> to store the entries a (1, Peter ) (20, Paul ) (15, Mary ) o (4, Beverly ) o o Using separate chaining we could implement the Map<K,V> interface J Seems fast, but how fast do we expect it to be?

40 Separate Chaining Analysis Assume the table has just 1 cell: All n items will be in a linked list => O(n) insert/find/remove L Assume the hash function h() always returns a constant value All n items will be in a linked list => O(n) insert/find/remove L Assume table has m cells AND h() evenly distributes the keys Every cell is equally likely to be selected to store key k, so the n items should be evenly distributed across m slots Average number of items per slot: n/m Also called the load factor (commonly written as α) Also the probability of a collision when inserting a new key Empty table: 0/m probability After 1 st item: 1/m After 2 nd item: 2/m Expected time for unsuccessful search: Expected time for successful search: O(1+n/m) O(1+n/m/2) => O(1+n/m) If n < c*m, then we can expect constant time! J

41 Next Steps 1. Reflect on the magic and power of Hash Tables! 2. Assignment 8 due Thursday November 10pm

42 Welcome to CS Questions?

CS : Data Structures

CS : Data Structures CS 600.226: Data Structures Michael Schatz Nov 5, 2018 Lecture 28. Hash Tables HW7 Assignment 7: Whispering Trees Out on: November 2, 2018 Due by: November 9, 2018 before 10:00 pm Collaboration: None Grading:

More information

CS : Data Structures

CS : Data Structures CS 600.226: Data Structures Michael Schatz Nov 11, 2016 Lecture 30: Advanced Hash Tables Assignment 9: Due Friday Nov 18 @ 10pm Remember: javac Xlint:all & checkstyle *.java & JUnit Solutions should be

More information

CS : Data Structures Michael Schatz. Nov 9, 2018 Lecture 30: Advanced Hash Tables

CS : Data Structures Michael Schatz. Nov 9, 2018 Lecture 30: Advanced Hash Tables CS 600.226: Data Structures Michael Schatz Nov 9, 2018 Lecture 30: Advanced Hash Tables HW7 Assignment 7: Whispering Trees Out on: November 2, 2018 Due by: November 9, 2018 before 10:00 pm Collaboration:

More information

Hash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell

Hash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell Hash Tables CS 311 Data Structures and Algorithms Lecture Slides Wednesday, April 22, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005

More information

Final Examination CSE 100 UCSD (Practice)

Final Examination CSE 100 UCSD (Practice) Final Examination UCSD (Practice) RULES: 1. Don t start the exam until the instructor says to. 2. This is a closed-book, closed-notes, no-calculator exam. Don t refer to any materials other than the exam

More information

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap DATA STRUCTURES AND ALGORITHMS Hierarchical data structures: AVL tree, Bayer tree, Heap Summary of the previous lecture TREE is hierarchical (non linear) data structure Binary trees Definitions Full tree,

More information

Balanced Binary Search Trees. Victor Gao

Balanced Binary Search Trees. Victor Gao Balanced Binary Search Trees Victor Gao OUTLINE Binary Heap Revisited BST Revisited Balanced Binary Search Trees Rotation Treap Splay Tree BINARY HEAP: REVIEW A binary heap is a complete binary tree such

More information

Sorted Arrays. Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min

Sorted Arrays. Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min Binary Search Trees FRIDAY ALGORITHMS Sorted Arrays Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min 6 10 11 17 2 0 6 Running Time O(1) O(lg n) O(1) O(1)

More information

CS : Data Structures

CS : Data Structures CS 600.226: Data Structures Michael Schatz Nov 30, 2016 Lecture 35: Topological Sorting Assignment 10: Due Monday Dec 5 @ 10pm Remember: javac Xlint:all & checkstyle *.java & JUnit Solutions should be

More information

Chapter 2: Basic Data Structures

Chapter 2: Basic Data Structures Chapter 2: Basic Data Structures Basic Data Structures Stacks Queues Vectors, Linked Lists Trees (Including Balanced Trees) Priority Queues and Heaps Dictionaries and Hash Tables Spring 2014 CS 315 2 Two

More information

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer) COSC 2007 Data Structures II Final Exam Thursday, April 13 th, 2006 This is a closed book and closed notes exam. There are total 3 parts. Please answer the questions in the provided space and use back

More information

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions:

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions: Direct Addressing - key is index into array => O(1) lookup Hash table: -hash function maps key to index in table -if universe of keys > # table entries then hash functions collision are guaranteed => need

More information

Lecture 5. Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs

Lecture 5. Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs Lecture 5 Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs Reading: Randomized Search Trees by Aragon & Seidel, Algorithmica 1996, http://sims.berkeley.edu/~aragon/pubs/rst96.pdf;

More information

INFO1x05 Tutorial 09

INFO1x05 Tutorial 09 INFO1x05 Tutorial 09 (2,3) Trees, (2,4) Trees and Hash Tables Exercise 1: (INFO1105 and INFO1905) Is the search tree shown below a (2,4) tree? Why or why not? 22 5 10 25 3 4 6 8 14 23 24 27 11 13 17 Figure

More information

CS102 Binary Search Trees

CS102 Binary Search Trees CS102 Binary Search Trees Prof Tejada 1 To speed up insertion, removal and search, modify the idea of a Binary Tree to create a Binary Search Tree (BST) Binary Search Trees Binary Search Trees have one

More information

CS Transform-and-Conquer

CS Transform-and-Conquer CS483-11 Transform-and-Conquer Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 1:30pm - 2:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/ lifei/teaching/cs483_fall07/

More information

Some Search Structures. Balanced Search Trees. Binary Search Trees. A Binary Search Tree. Review Binary Search Trees

Some Search Structures. Balanced Search Trees. Binary Search Trees. A Binary Search Tree. Review Binary Search Trees Some Search Structures Balanced Search Trees Lecture 8 CS Fall Sorted Arrays Advantages Search in O(log n) time (binary search) Disadvantages Need to know size in advance Insertion, deletion O(n) need

More information

Lecture 13: AVL Trees and Binary Heaps

Lecture 13: AVL Trees and Binary Heaps Data Structures Brett Bernstein Lecture 13: AVL Trees and Binary Heaps Review Exercises 1. ( ) Interview question: Given an array show how to shue it randomly so that any possible reordering is equally

More information

Balanced Search Trees. CS 3110 Fall 2010

Balanced Search Trees. CS 3110 Fall 2010 Balanced Search Trees CS 3110 Fall 2010 Some Search Structures Sorted Arrays Advantages Search in O(log n) time (binary search) Disadvantages Need to know size in advance Insertion, deletion O(n) need

More information

Binary Search Trees Treesort

Binary Search Trees Treesort Treesort CS 311 Data Structures and Algorithms Lecture Slides Friday, November 13, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009

More information

CSE100. Advanced Data Structures. Lecture 8. (Based on Paul Kube course materials)

CSE100. Advanced Data Structures. Lecture 8. (Based on Paul Kube course materials) CSE100 Advanced Data Structures Lecture 8 (Based on Paul Kube course materials) CSE 100 Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs

More information

Quiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g)

Quiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g) Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology 6.006 Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1 Solutions Problem 1. Quiz 1 Solutions Asymptotic orders

More information

Lecture 6: Analysis of Algorithms (CS )

Lecture 6: Analysis of Algorithms (CS ) Lecture 6: Analysis of Algorithms (CS583-002) Amarda Shehu October 08, 2014 1 Outline of Today s Class 2 Traversals Querying Insertion and Deletion Sorting with BSTs 3 Red-black Trees Height of a Red-black

More information

Data Structures in Java

Data Structures in Java Data Structures in Java Lecture 10: AVL Trees. 10/1/015 Daniel Bauer Balanced BSTs Balance condition: Guarantee that the BST is always close to a complete binary tree (every node has exactly two or zero

More information

CS 380 ALGORITHM DESIGN AND ANALYSIS

CS 380 ALGORITHM DESIGN AND ANALYSIS CS 380 ALGORITHM DESIGN AND ANALYSIS Lecture 12: Red-Black Trees Text Reference: Chapters 12, 13 Binary Search Trees (BST): Review Each node in tree T is a object x Contains attributes: Data Pointers to

More information

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree. The Lecture Contains: Index structure Binary search tree (BST) B-tree B+-tree Order file:///c /Documents%20and%20Settings/iitkrana1/My%20Documents/Google%20Talk%20Received%20Files/ist_data/lecture13/13_1.htm[6/14/2012

More information

CS 206 Introduction to Computer Science II

CS 206 Introduction to Computer Science II CS 206 Introduction to Computer Science II 04 / 26 / 2017 Instructor: Michael Eckmann Today s Topics Questions? Comments? Balanced Binary Search trees AVL trees Michael Eckmann - Skidmore College - CS

More information

Algorithms. AVL Tree

Algorithms. AVL Tree Algorithms AVL Tree Balanced binary tree The disadvantage of a binary search tree is that its height can be as large as N-1 This means that the time needed to perform insertion and deletion and many other

More information

Search Trees. Undirected graph Directed graph Tree Binary search tree

Search Trees. Undirected graph Directed graph Tree Binary search tree Search Trees Undirected graph Directed graph Tree Binary search tree 1 Binary Search Tree Binary search key property: Let x be a node in a binary search tree. If y is a node in the left subtree of x, then

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 9 - Jan. 22, 2018 CLRS 12.2, 12.3, 13.2, read problem 13-3 University of Manitoba COMP 3170 - Analysis of Algorithms & Data Structures

More information

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 7. (A subset of) the Collections Interface. The Java Collections Interfaces

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 7. (A subset of) the Collections Interface. The Java Collections Interfaces Taking Stock IE170: Algorithms in Systems Engineering: Lecture 7 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University January 29, 2007 Last Time Practice Some Sorting Algs

More information

CSE100. Advanced Data Structures. Lecture 21. (Based on Paul Kube course materials)

CSE100. Advanced Data Structures. Lecture 21. (Based on Paul Kube course materials) CSE100 Advanced Data Structures Lecture 21 (Based on Paul Kube course materials) CSE 100 Collision resolution strategies: linear probing, double hashing, random hashing, separate chaining Hash table cost

More information

BINARY HEAP cs2420 Introduction to Algorithms and Data Structures Spring 2015

BINARY HEAP cs2420 Introduction to Algorithms and Data Structures Spring 2015 BINARY HEAP cs2420 Introduction to Algorithms and Data Structures Spring 2015 1 administrivia 2 -assignment 10 is due on Thursday -midterm grades out tomorrow 3 last time 4 -a hash table is a general storage

More information

ECE 242 Data Structures and Algorithms. Trees IV. Lecture 21. Prof.

ECE 242 Data Structures and Algorithms.  Trees IV. Lecture 21. Prof. ECE 22 Data Structures and Algorithms http://www.ecs.umass.edu/~polizzi/teaching/ece22/ Trees IV Lecture 2 Prof. Eric Polizzi Summary previous lectures Implementations BST 5 5 7 null 8 null null 7 null

More information

CS 234. Module 8. November 15, CS 234 Module 8 ADT Priority Queue 1 / 22

CS 234. Module 8. November 15, CS 234 Module 8 ADT Priority Queue 1 / 22 CS 234 Module 8 November 15, 2018 CS 234 Module 8 ADT Priority Queue 1 / 22 ADT Priority Queue Data: (key, element pairs) where keys are orderable but not necessarily distinct, and elements are any data.

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms Spring 2017-2018 Outline 1 Priority Queues Outline Priority Queues 1 Priority Queues Jumping the Queue Priority Queues In normal queue, the mode of selection is first in,

More information

Friday Four Square! 4:15PM, Outside Gates

Friday Four Square! 4:15PM, Outside Gates Binary Search Trees Friday Four Square! 4:15PM, Outside Gates Implementing Set On Monday and Wednesday, we saw how to implement the Map and Lexicon, respectively. Let's now turn our attention to the Set.

More information

CS 251, LE 2 Fall MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY

CS 251, LE 2 Fall MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY CS 251, LE 2 Fall 2016 MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY W1.) (i) Show one possible valid 2-3 tree containing the nine elements: 1 3 4 5 6 8 9 10 12. (ii) Draw the final binary search

More information

Lecture: Analysis of Algorithms (CS )

Lecture: Analysis of Algorithms (CS ) Lecture: Analysis of Algorithms (CS583-002) Amarda Shehu Fall 2017 1 Binary Search Trees Traversals, Querying, Insertion, and Deletion Sorting with BSTs 2 Example: Red-black Trees Height of a Red-black

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 9 - Jan. 22, 2018 CLRS 12.2, 12.3, 13.2, read problem 13-3 University of Manitoba 1 / 12 Binary Search Trees (review) Structure

More information

Section 4 SOLUTION: AVL Trees & B-Trees

Section 4 SOLUTION: AVL Trees & B-Trees Section 4 SOLUTION: AVL Trees & B-Trees 1. What 3 properties must an AVL tree have? a. Be a binary tree b. Have Binary Search Tree ordering property (left children < parent, right children > parent) c.

More information

Module 4: Dictionaries and Balanced Search Trees

Module 4: Dictionaries and Balanced Search Trees Module 4: Dictionaries and Balanced Search Trees CS 24 - Data Structures and Data Management Jason Hinek and Arne Storjohann Based on lecture notes by R. Dorrigiv and D. Roche David R. Cheriton School

More information

Self-Balancing Search Trees. Chapter 11

Self-Balancing Search Trees. Chapter 11 Self-Balancing Search Trees Chapter 11 Chapter Objectives To understand the impact that balance has on the performance of binary search trees To learn about the AVL tree for storing and maintaining a binary

More information

CSC Design and Analysis of Algorithms

CSC Design and Analysis of Algorithms CSC : Lecture 7 CSC - Design and Analysis of Algorithms Lecture 7 Transform and Conquer I Algorithm Design Technique CSC : Lecture 7 Transform and Conquer This group of techniques solves a problem by a

More information

CS350: Data Structures Red-Black Trees

CS350: Data Structures Red-Black Trees Red-Black Trees James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Red-Black Tree An alternative to AVL trees Insertion can be done in a bottom-up or

More information

Advanced Set Representation Methods

Advanced Set Representation Methods Advanced Set Representation Methods AVL trees. 2-3(-4) Trees. Union-Find Set ADT DSA - lecture 4 - T.U.Cluj-Napoca - M. Joldos 1 Advanced Set Representation. AVL Trees Problem with BSTs: worst case operation

More information

CSE 100: UNION-FIND HASH

CSE 100: UNION-FIND HASH CSE 100: UNION-FIND HASH Run time of Simple union and find (using up-trees) If we have no rule in place for performing the union of two up trees, what is the worst case run time of find and union operations

More information

Priority Queues and Binary Heaps

Priority Queues and Binary Heaps Yufei Tao ITEE University of Queensland In this lecture, we will learn our first tree data structure called the binary heap which serves as an implementation of the priority queue. Priority Queue A priority

More information

CS : Data Structures

CS : Data Structures CS 600.226: Data Structures Michael Schatz Oct 12, 2016 Lecture 17: Trees Assignment 5: Due Sunday Oct 9 @ 10pm Remember: javac Xlint:all & checkstyle *.java & JUnit Solutions should be independently written!

More information

CS S-08 Priority Queues Heaps 1

CS S-08 Priority Queues Heaps 1 CS245-2015S-08 Priority Queues Heaps 1 08-0: Priority Queue ADT Keys are priorities, with smaller keys having a better priority 08-1: Priority Queue ADT Sorted Array Add Element Remove Smallest Key 08-2:

More information

Lecture Summary CSC 263H. August 5, 2016

Lecture Summary CSC 263H. August 5, 2016 Lecture Summary CSC 263H August 5, 2016 This document is a very brief overview of what we did in each lecture, it is by no means a replacement for attending lecture or doing the readings. 1. Week 1 2.

More information

CSC Design and Analysis of Algorithms. Lecture 7. Transform and Conquer I Algorithm Design Technique. Transform and Conquer

CSC Design and Analysis of Algorithms. Lecture 7. Transform and Conquer I Algorithm Design Technique. Transform and Conquer // CSC - Design and Analysis of Algorithms Lecture 7 Transform and Conquer I Algorithm Design Technique Transform and Conquer This group of techniques solves a problem by a transformation to a simpler/more

More information

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 2. O(n) 2. [1 pt] What is the solution to the recurrence T(n) = T(n/2) + n, T(1)

More information

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs Computational Optimization ISE 407 Lecture 16 Dr. Ted Ralphs ISE 407 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms in

More information

Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1

Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1 Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology 6.006 Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1 Quiz 1 Do not open this quiz booklet until directed to

More information

CSE373: Data Structures & Algorithms Lecture 4: Dictionaries; Binary Search Trees. Kevin Quinn Fall 2015

CSE373: Data Structures & Algorithms Lecture 4: Dictionaries; Binary Search Trees. Kevin Quinn Fall 2015 CSE373: Data Structures & Algorithms Lecture 4: Dictionaries; Binary Search Trees Kevin Quinn Fall 2015 Where we are Studying the absolutely essential ADTs of computer science and classic data structures

More information

Lecture 7. Transform-and-Conquer

Lecture 7. Transform-and-Conquer Lecture 7 Transform-and-Conquer 6-1 Transform and Conquer This group of techniques solves a problem by a transformation to a simpler/more convenient instance of the same problem (instance simplification)

More information

Data Structures in Java

Data Structures in Java Data Structures in Java Lecture 9: Binary Search Trees. 10/7/015 Daniel Bauer 1 Contents 1. Binary Search Trees. Implementing Maps with BSTs Map ADT A map is collection of (key, value) pairs. Keys are

More information

CS-301 Data Structure. Tariq Hanif

CS-301 Data Structure. Tariq Hanif 1. The tree data structure is a Linear data structure Non-linear data structure Graphical data structure Data structure like queue FINALTERM EXAMINATION Spring 2012 CS301- Data Structure 25-07-2012 2.

More information

CSE332: Data Abstractions Lecture 7: B Trees. James Fogarty Winter 2012

CSE332: Data Abstractions Lecture 7: B Trees. James Fogarty Winter 2012 CSE2: Data Abstractions Lecture 7: B Trees James Fogarty Winter 20 The Dictionary (a.k.a. Map) ADT Data: Set of (key, value) pairs keys must be comparable insert(jfogarty,.) Operations: insert(key,value)

More information

CSE 100 Advanced Data Structures

CSE 100 Advanced Data Structures CSE 100 Advanced Data Structures Overview of course requirements Outline of CSE 100 topics Review of trees Helpful hints for team programming Information about computer accounts Page 1 of 25 CSE 100 web

More information

Red-Black Trees. Based on materials by Dennis Frey, Yun Peng, Jian Chen, and Daniel Hood

Red-Black Trees. Based on materials by Dennis Frey, Yun Peng, Jian Chen, and Daniel Hood Red-Black Trees Based on materials by Dennis Frey, Yun Peng, Jian Chen, and Daniel Hood Quick Review of Binary Search Trees n Given a node n... q All elements of n s left subtree are less than n.data q

More information

Data Structure. A way to store and organize data in order to support efficient insertions, queries, searches, updates, and deletions.

Data Structure. A way to store and organize data in order to support efficient insertions, queries, searches, updates, and deletions. DATA STRUCTURES COMP 321 McGill University These slides are mainly compiled from the following resources. - Professor Jaehyun Park slides CS 97SI - Top-coder tutorials. - Programming Challenges book. Data

More information

9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology

9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology Introduction Chapter 4 Trees for large input, even linear access time may be prohibitive we need data structures that exhibit average running times closer to O(log N) binary search tree 2 Terminology recursive

More information

Cpt S 223 Fall Cpt S 223. School of EECS, WSU

Cpt S 223 Fall Cpt S 223. School of EECS, WSU Course Review Cpt S 223 Fall 2012 1 Final Exam When: Monday (December 10) 8 10 AM Where: in class (Sloan 150) Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes

More information

Course Review. Cpt S 223 Fall 2010

Course Review. Cpt S 223 Fall 2010 Course Review Cpt S 223 Fall 2010 1 Final Exam When: Thursday (12/16) 8-10am Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes Homeworks & program

More information

Introduction. for large input, even access time may be prohibitive we need data structures that exhibit times closer to O(log N) binary search tree

Introduction. for large input, even access time may be prohibitive we need data structures that exhibit times closer to O(log N) binary search tree Chapter 4 Trees 2 Introduction for large input, even access time may be prohibitive we need data structures that exhibit running times closer to O(log N) binary search tree 3 Terminology recursive definition

More information

1 CSE 100: HASH TABLES

1 CSE 100: HASH TABLES CSE 100: HASH TABLES 1 2 Looking ahead.. Watch out for those deadlines Where we ve been and where we are going Our goal so far: We want to store and retrieve data (keys) fast 3 Tree structures BSTs: simple,

More information

UNIT III BALANCED SEARCH TREES AND INDEXING

UNIT III BALANCED SEARCH TREES AND INDEXING UNIT III BALANCED SEARCH TREES AND INDEXING OBJECTIVE The implementation of hash tables is frequently called hashing. Hashing is a technique used for performing insertions, deletions and finds in constant

More information

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs Algorithms in Systems Engineering ISE 172 Lecture 16 Dr. Ted Ralphs ISE 172 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms

More information

CSE 332, Spring 2010, Midterm Examination 30 April 2010

CSE 332, Spring 2010, Midterm Examination 30 April 2010 CSE 332, Spring 2010, Midterm Examination 30 April 2010 Please do not turn the page until the bell rings. Rules: The exam is closed-book, closed-note. You may use a calculator for basic arithmetic only.

More information

Practice Midterm Exam Solutions

Practice Midterm Exam Solutions CSE 332: Data Abstractions Autumn 2015 Practice Midterm Exam Solutions Name: Sample Solutions ID #: 1234567 TA: The Best Section: A9 INSTRUCTIONS: You have 50 minutes to complete the exam. The exam is

More information

Balanced Binary Search Trees

Balanced Binary Search Trees Balanced Binary Search Trees Pedro Ribeiro DCC/FCUP 2017/2018 Pedro Ribeiro (DCC/FCUP) Balanced Binary Search Trees 2017/2018 1 / 48 Motivation Let S be a set of comparable objects/items: Let a and b be

More information

Section 1: True / False (1 point each, 15 pts total)

Section 1: True / False (1 point each, 15 pts total) Section : True / False ( point each, pts total) Circle the word TRUE or the word FALSE. If neither is circled, both are circled, or it impossible to tell which is circled, your answer will be considered

More information

9. Heap : Priority Queue

9. Heap : Priority Queue 9. Heap : Priority Queue Where We Are? Array Linked list Stack Queue Tree Binary Tree Heap Binary Search Tree Priority Queue Queue Queue operation is based on the order of arrivals of elements FIFO(First-In

More information

Recall: Properties of B-Trees

Recall: Properties of B-Trees CSE 326 Lecture 10: B-Trees and Heaps It s lunch time what s cookin? B-Trees Insert/Delete Examples and Run Time Analysis Summary of Search Trees Introduction to Heaps and Priority Queues Covered in Chapters

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms CS245-2008S-19 B-Trees David Galles Department of Computer Science University of San Francisco 19-0: Indexing Operations: Add an element Remove an element Find an element,

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms CS245-2015S-08 Priority Queues Heaps David Galles Department of Computer Science University of San Francisco 08-0: Priority Queue ADT Operations Add an element / key pair

More information

COMP251: Algorithms and Data Structures. Jérôme Waldispühl School of Computer Science McGill University

COMP251: Algorithms and Data Structures. Jérôme Waldispühl School of Computer Science McGill University COMP251: Algorithms and Data Structures Jérôme Waldispühl School of Computer Science McGill University About Me Jérôme Waldispühl Associate Professor of Computer Science I am conducting research in Bioinformatics

More information

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya CS62: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Binary Search Tree - Best Time All BST operations are O(d), where d is tree depth minimum d is d = ëlog for a binary tree

More information

The questions will be short answer, similar to the problems you have done on the homework

The questions will be short answer, similar to the problems you have done on the homework Introduction The following highlights are provided to give you an indication of the topics that you should be knowledgeable about for the midterm. This sheet is not a substitute for the homework and the

More information

Trees. Reading: Weiss, Chapter 4. Cpt S 223, Fall 2007 Copyright: Washington State University

Trees. Reading: Weiss, Chapter 4. Cpt S 223, Fall 2007 Copyright: Washington State University Trees Reading: Weiss, Chapter 4 1 Generic Rooted Trees 2 Terms Node, Edge Internal node Root Leaf Child Sibling Descendant Ancestor 3 Tree Representations n-ary trees Each internal node can have at most

More information

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya CS62: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Balanced search trees Balanced search tree: A search-tree data structure for which a height of O(lg n) is guaranteed when

More information

CS : Data Structures

CS : Data Structures CS 600.226: Data Structures Michael Schatz Sept 21, 2016 Lecture 8: Sorting Assignment 3: Due Sunday Sept 25 @ 10pm Remember: javac Xlint:all & checkstyle *.java Solutions should be independently written!

More information

Learning Goals. CS221: Algorithms and Data Structures Lecture #3 Mind Your Priority Queues. Today s Outline. Back to Queues. Priority Queue ADT

Learning Goals. CS221: Algorithms and Data Structures Lecture #3 Mind Your Priority Queues. Today s Outline. Back to Queues. Priority Queue ADT CS: Algorithms and Data Structures Lecture # Mind Your Priority Queues Steve Wolfman 0W Learning Goals Provide examples of appropriate applications for priority queues. Describe efficient implementations

More information

CMSC 341 Priority Queues & Heaps. Based on slides from previous iterations of this course

CMSC 341 Priority Queues & Heaps. Based on slides from previous iterations of this course CMSC 341 Priority Queues & Heaps Based on slides from previous iterations of this course Today s Topics Priority Queues Abstract Data Type Implementations of Priority Queues: Lists BSTs Heaps Heaps Properties

More information

Binary Search Trees, etc.

Binary Search Trees, etc. Chapter 12 Binary Search Trees, etc. Binary Search trees are data structures that support a variety of dynamic set operations, e.g., Search, Minimum, Maximum, Predecessors, Successors, Insert, and Delete.

More information

Treaps. 1 Binary Search Trees (BSTs) CSE341T/CSE549T 11/05/2014. Lecture 19

Treaps. 1 Binary Search Trees (BSTs) CSE341T/CSE549T 11/05/2014. Lecture 19 CSE34T/CSE549T /05/04 Lecture 9 Treaps Binary Search Trees (BSTs) Search trees are tree-based data structures that can be used to store and search for items that satisfy a total order. There are many types

More information

CIS265/ Trees Red-Black Trees. Some of the following material is from:

CIS265/ Trees Red-Black Trees. Some of the following material is from: CIS265/506 2-3-4 Trees Red-Black Trees Some of the following material is from: Data Structures for Java William H. Ford William R. Topp ISBN 0-13-047724-9 Chapter 27 Balanced Search Trees Bret Ford 2005,

More information

Course Review. Cpt S 223 Fall 2009

Course Review. Cpt S 223 Fall 2009 Course Review Cpt S 223 Fall 2009 1 Final Exam When: Tuesday (12/15) 8-10am Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes Homeworks & program

More information

W4231: Analysis of Algorithms

W4231: Analysis of Algorithms W4231: Analysis of Algorithms 10/5/1999 (revised 10/6/1999) More hashing Binomial heaps Lectures Next Week No Lecture Tues. October 12 and Thurs. October 14. Extra lecture (2 1 2 hours) on Mon. October

More information

l Heaps very popular abstract data structure, where each object has a key value (the priority), and the operations are:

l Heaps very popular abstract data structure, where each object has a key value (the priority), and the operations are: DDS-Heaps 1 Heaps - basics l Heaps very popular abstract data structure, where each object has a key value (the priority), and the operations are: l insert an object, find the object of minimum key (find

More information

CSE 332: Data Structures & Parallelism Lecture 7: Dictionaries; Binary Search Trees. Ruth Anderson Winter 2019

CSE 332: Data Structures & Parallelism Lecture 7: Dictionaries; Binary Search Trees. Ruth Anderson Winter 2019 CSE 332: Data Structures & Parallelism Lecture 7: Dictionaries; Binary Search Trees Ruth Anderson Winter 2019 Today Dictionaries Trees 1/23/2019 2 Where we are Studying the absolutely essential ADTs of

More information

CSE 100 Tutor Review Section. Anish, Daniel, Galen, Raymond

CSE 100 Tutor Review Section. Anish, Daniel, Galen, Raymond CSE 100 Tutor Review Section Anish, Daniel, Galen, Raymond THIS MAY NOT COVER EVERYTHING... Such as C++ / code implementation, and everything else in the lecture slides that s not in here. - Go over lecture

More information

CSE 332: Data Structures & Parallelism Lecture 3: Priority Queues. Ruth Anderson Winter 2019

CSE 332: Data Structures & Parallelism Lecture 3: Priority Queues. Ruth Anderson Winter 2019 CSE 332: Data Structures & Parallelism Lecture 3: Priority Queues Ruth Anderson Winter 201 Today Finish up Intro to Asymptotic Analysis New ADT! Priority Queues 1/11/201 2 Scenario What is the difference

More information

l So unlike the search trees, there are neither arbitrary find operations nor arbitrary delete operations possible.

l So unlike the search trees, there are neither arbitrary find operations nor arbitrary delete operations possible. DDS-Heaps 1 Heaps - basics l Heaps an abstract structure where each object has a key value (the priority), and the operations are: insert an object, find the object of minimum key (find min), and delete

More information

CSC Design and Analysis of Algorithms. Lecture 7. Transform and Conquer I Algorithm Design Technique. Transform and Conquer

CSC Design and Analysis of Algorithms. Lecture 7. Transform and Conquer I Algorithm Design Technique. Transform and Conquer CSC 83- Design and Analysis of Algorithms Lecture 7 Transform and Conuer I Algorithm Design Techniue Transform and Conuer This group of techniues solves a problem by a transformation to a simpler/more

More information

Priority Queues. 04/10/03 Lecture 22 1

Priority Queues. 04/10/03 Lecture 22 1 Priority Queues It is a variant of queues Each item has an associated priority value. When inserting an item in the queue, the priority value is also provided for it. The data structure provides a method

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 10: Search and Heaps MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Search and Heaps 2 Linear Search Binary Search Introduction to trees Priority Queues Heaps Linear Search

More information

Trees. Eric McCreath

Trees. Eric McCreath Trees Eric McCreath 2 Overview In this lecture we will explore: general trees, binary trees, binary search trees, and AVL and B-Trees. 3 Trees Trees are recursive data structures. They are useful for:

More information