Welcome to IT 516! Data Structures & Algorithms Review of Linked Lists Parallel ordered arrays Binary Search Trees Tom Becker Summerr 2018 Lecture 7
IT WeekDateTopics Weekly Assignments 105/23/18Introduction, Quick Find/Union, WQFHW 1,2,3 205/30/18Bags, Stacks, QueuesHW /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
CSC521 Spring 2011 Lecture 1 7 KEYVALUE A A 4.00 A B+3.33 … D1.00 Symbol Table Example – GPA – Create a ST
CSC521 Spring 2011 Lecture 1 8 KEYVALUE A A 4.00 A B+3.33 … D1.00 Symbol Table Example -- GPA Create a ST ST grades = new ST ();
CSC521 Spring 2011 Lecture 1 9 KEYVALUE A A 4.00 A 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??
Lecture 1 10 KEYVALUE A A 4.00 A B+3.33 … D1.00 Symbol Table Example -- GPA String key = StdIn.readString(); st.put(key, i); } for (int i = 0; !StdIn.isEmpty(); i++) {
CSC521 Spring 2011 Lecture 1 11 Symbol Table Exercise
So How can we actually implement Symbol Tables?
OOPs If match – change value
Everyone remember Binary Search??? So the order of Binary Search is ______??? BUT… what am I forgetting?
This Uses 2 fast parallel arrays !!
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!
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!
This tree has nodes with information in them…
What’s the difference with nodes in a HEAP??
LETS do some demonstrations on a different tree ….
For the GET operation we would RETURN the KEY and VALUE stored here!!
To INSERT G – Do the SAME Search Steps and – insert it!!
EXAMPLESEARCH Take a sheet of paper and create a BST for this text string:
E A C X M L H P S R EXAMPLE SEARCH … one of many! Binary search Tree For
A C E H R S X Take a sheet of paper and create a BST for this text string:
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:
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 :
Try this demo: BST Demonstration
What (1) thing was critical for the success of Quicksort?
EXTRA Slides