Download presentation
Presentation is loading. Please wait.
Published byYu-Chun Chou Modified over 6 years ago
1
Welcome to IT 516! Data Structures & Algorithms Review of Linked Lists Parallel ordered arrays Binary Search Trees Tom Becker Summerr 2018 Lecture 7
3
IT 516 3 WeekDateTopics Weekly Assignments 105/23/18Introduction, Quick Find/Union, WQFHW 1,2,3 205/30/18Bags, Stacks, QueuesHW 4 3 06/6/18Algorithm Analysis, Elementary Sorts (Selection, Insertion, Shuffle sorts ) HW 5 406/13/18Merge sort, Quicksort HW 6 506/20/18Priority Queues, Heaps, Heap correctHW 7 606/27/18MT EXAM, Heapsort Symbol Tables, BSTs Searching, HW8 707/11/18BSTs, HashingHW 9 807/18/18 Undirected Graphs, Directed Graphs HW 907/25/18Data CompressionHW 1008/01/18Final ExamHW 11 OVERVIEW OF TOPICS AND SCHEDULE OF TOPICS AND ACTIVITIES
7
CSC521 Spring 2011 Lecture 1 7 KEYVALUE A+ 4.33 A 4.00 A- 3.67 B+3.33 … D1.00 Symbol Table Example – GPA – Create a ST
8
CSC521 Spring 2011 Lecture 1 8 KEYVALUE A+ 4.33 A 4.00 A- 3.67 B+3.33 … D1.00 Symbol Table Example -- GPA Create a ST ST grades = new ST ();
9
CSC521 Spring 2011 Lecture 1 9 KEYVALUE A+ 4.33 A 4.00 A- 3.67 B+3.33 … D1.00 Symbol Table Example -- GPA ST grades = new ST (); grades.put("A+", 4.33); ….What if I wanted to input these pairs from a file??
10
Lecture 1 10 KEYVALUE A+ 4.33 A 4.00 A- 3.67 B+3.33 … D1.00 Symbol Table Example -- GPA String key = StdIn.readString(); st.put(key, i); } for (int i = 0; !StdIn.isEmpty(); i++) {
11
CSC521 Spring 2011 Lecture 1 11 Symbol Table Exercise
16
So How can we actually implement Symbol Tables?
18
OOPs If match – change value
20
Everyone remember Binary Search??? https://www.youtube.com/watch?v=P3YID7liBug So the order of Binary Search is ______??? BUT… what am I forgetting?
22
This Uses 2 fast parallel arrays !!
24
KEY array - sorted list of values. To find a value associated with a particular KEY, You need to binary search keys[] array by VALUE, then look in that position in the vals[] array!! Don’t confuse the VALUE with the positions in keys array – the VALUE for X is in the same position in the vals array… We keep the VALUE for a KEY in the same array position as the KEY is in!
25
WHILE log N for SEARCH is excellent (Binary searching is just very HARD to Beat!!!) the ORDER of inserts is still proportional to N/2 which is just TOO SLOW!
31
This tree has nodes with information in them…
32
What’s the difference with nodes in a HEAP??
36
LETS do some demonstrations on a different tree ….
41
For the GET operation we would RETURN the KEY and VALUE stored here!!
48
To INSERT G – Do the SAME Search Steps and – insert it!!
57
EXAMPLESEARCH Take a sheet of paper and create a BST for this text string:
58
E A C X M L H P S R EXAMPLE SEARCH … one of many! Binary search Tree For
59
A C E H R S X Take a sheet of paper and create a BST for this text string:
60
A C E H R S X Take a sheet of paper and create a BST for this text string: H C S A E R X Now this one:
61
A C E H R S X Take a sheet of paper and create a BST for this text string: H C S A E R X Now this one: X S R H E C A And Last :
63
Try this demo: https://algs4.cs.princeton.edu/32bst/https://algs4.cs.princeton.edu/32bst/ BST Demonstration
67
What (1) thing was critical for the success of Quicksort?
73
EXTRA Slides
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.