Presentation is loading. Please wait.

Presentation is loading. Please wait.

Welcome to IT 516! Data Structures & Algorithms Review of Linked Lists Parallel ordered arrays Binary Search Trees Tom Becker Summerr 2018 Lecture 7.

Similar presentations


Presentation on theme: "Welcome to IT 516! Data Structures & Algorithms Review of Linked Lists Parallel ordered arrays Binary Search Trees Tom Becker Summerr 2018 Lecture 7."— Presentation transcript:

1 Welcome to IT 516! Data Structures & Algorithms Review of Linked Lists Parallel ordered arrays Binary Search Trees Tom Becker Summerr 2018 Lecture 7

2

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

4

5

6

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

12

13

14

15

16 So How can we actually implement Symbol Tables?

17

18 OOPs  If match – change value

19

20 Everyone remember Binary Search??? https://www.youtube.com/watch?v=P3YID7liBug So the order of Binary Search is ______??? BUT… what am I forgetting?

21

22 This Uses 2 fast parallel arrays !!

23

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!

26

27

28

29

30

31 This tree has nodes with information in them…

32 What’s the difference with nodes in a HEAP??

33

34

35

36 LETS do some demonstrations on a different tree ….

37

38

39

40

41 For the GET operation we would RETURN the KEY and VALUE stored here!!

42

43

44

45

46

47

48 To INSERT G – Do the SAME Search Steps and – insert it!!

49

50

51

52

53

54

55

56

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 :

62

63 Try this demo: https://algs4.cs.princeton.edu/32bst/https://algs4.cs.princeton.edu/32bst/ BST Demonstration

64

65

66

67 What (1) thing was critical for the success of Quicksort?

68

69

70

71

72

73 EXTRA Slides

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89


Download ppt "Welcome to IT 516! Data Structures & Algorithms Review of Linked Lists Parallel ordered arrays Binary Search Trees Tom Becker Summerr 2018 Lecture 7."

Similar presentations


Ads by Google