1 Sorting/Searching CS308 Data Structures. 2 Sorting means... l Sorting rearranges the elements into either ascending or descending order within the array.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms Quicksort
Advertisements

Garfield AP Computer Science
Sorting A fundamental operation in computer science (many programs need to sort as an intermediate step). Many sorting algorithms have been developed Choose.
Searching and Sorting Algorithms Based on D. S
Stephen P. Carl - CS 2421 Recursive Sorting Algorithms Reading: Chapter 5.
Sorting Algorithms and Average Case Time Complexity
Sorting Chapter Sorting Consider list x 1, x 2, x 3, … x n We seek to arrange the elements of the list in order –Ascending or descending Some O(n.
CS203 Programming with Data Structures Sorting California State University, Los Angeles.
CS Data Structures I Chapter 10 Algorithm Efficiency & Sorting III.
Section 8.8 Heapsort.  Merge sort time is O(n log n) but still requires, temporarily, n extra storage locations  Heapsort does not require any additional.
Ver. 1.0 Session 5 Data Structures and Algorithms Objectives In this session, you will learn to: Sort data by using quick sort Sort data by using merge.
Chapter 11 Sorting and Searching. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Examine the linear search and.
1 C++ Plus Data Structures Nell Dale Chapter 10 Sorting and Searching Algorithms Slides by Sylvia Sorkin, Community College of Baltimore County - Essex.
Sorting Algorithms Selection, Bubble, Insertion and Radix Sort.
CHAPTER 11 Sorting.
C++ Plus Data Structures
Chapter 3: Sorting and Searching Algorithms 3.2 Simple Sort: O(n 2 )
Sorting Chapter 10.
Sorting Algorithms Insertion and Radix Sort. Insertion Sort One by one, each as yet unsorted array element is inserted into its proper place with respect.
Algorithms for Sorting Things. Why do we need to sort things? Internal Telephone Directory –sorted by department then by name My local video store holds.
Sorting CS-212 Dick Steflik. Exchange Sorting Method : make n-1 passes across the data, on each pass compare adjacent items, swapping as necessary (n-1.
Sorting Chapter 10. Chapter 10: Sorting2 Chapter Objectives To learn how to use the standard sorting methods in the Java API To learn how to implement.
MergeSort Source: Gibbs & Tamassia. 2 MergeSort MergeSort is a divide and conquer method of sorting.
1 Data Structures and Algorithms Sorting. 2  Sorting is the process of arranging a list of items into a particular order  There must be some value on.
1 Data Structures and Algorithms Sorting and Searching Algorithms Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus and Robert.
CHAPTER 09 Compiled by: Dr. Mohammad Omar Alhawarat Sorting & Searching.
Sorting. Introduction Common problem: sort a list of values, starting from lowest to highest. List of exam scores Words of dictionary in alphabetical.
Fall 2013 Instructor: Reza Entezari-Maleki Sharif University of Technology 1 Fundamentals of Programming Session 17 These.
CSCE 3110 Data Structures & Algorithm Analysis Sorting (I) Reading: Chap.7, Weiss.
1 Programming with Recursion. 2 Recursive Function Call A recursive call is a function call in which the called function is the same as the one making.
Chapter 10 Sorting and Searching Algorithms. Chapter 10: Sorting and Searching Algorithms 10.1 – Sorting 10.2 – Simple Sorts 10.3 – O(N log 2 N) Sorts.
Merge Sort. What Is Sorting? To arrange a collection of items in some specified order. Numerical order Lexicographical order Input: sequence of numbers.
Chapter 10 B Algorithm Efficiency and Sorting. © 2004 Pearson Addison-Wesley. All rights reserved 9 A-2 Sorting Algorithms and Their Efficiency Sorting.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 19: Searching and Sorting.
Sorting Chapter 10. Chapter Objectives  To learn how to use the standard sorting methods in the Java API  To learn how to implement the following sorting.
Sorting. Pseudocode of Insertion Sort Insertion Sort To sort array A[0..n-1], sort A[0..n-2] recursively and then insert A[n-1] in its proper place among.
Chapter 5 Searching and Sorting. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter Objectives Examine the linear search and binary.
Sorting Chapter Sorting Consider list x 1, x 2, x 3, … x n We seek to arrange the elements of the list in order –Ascending or descending Some O(n.
1 C++ Plus Data Structures Nell Dale Chapter 10 Sorting and Searching Algorithms Slides by Sylvia Sorkin, Community College of Baltimore County - Essex.
Sorting CS Sorting means... Sorting rearranges the elements into either ascending or descending order within the array. (we’ll use ascending order.)
Sorting and Searching. Selection Sort  “Search-and-Swap” algorithm 1) Find the smallest element in the array and exchange it with a[0], the first element.
Chapter 8 Sorting and Searching Goals: 1.Java implementation of sorting algorithms 2.Selection and Insertion Sorts 3.Recursive Sorts: Mergesort and Quicksort.
Review 1 Selection Sort Selection Sort Algorithm Time Complexity Best case Average case Worst case Examples.
Lecture No. 04,05 Sorting.  A process that organizes a collection of data into either ascending or descending order.  Can be used as a first step for.
1 Searching and Sorting Searching algorithms with simple arrays Sorting algorithms with simple arrays –Selection Sort –Insertion Sort –Bubble Sort –Quick.
HEAPS. Review: what are the requirements of the abstract data type: priority queue? Quick removal of item with highest priority (highest or lowest key.
Sorting and Searching Algorithms CS Sorting means... l The values stored in an array have keys of a type for which the relational operators are.
Selection Sort Given an array[0-N], place the smallest item in the array in position 0, the second smallest in position 1, and so forth. We do thisby comparing.
Chapter 4, Part II Sorting Algorithms. 2 Heap Details A heap is a tree structure where for each subtree the value stored at the root is larger than all.
PREVIOUS SORTING ALGORITHMS  BUBBLE SORT –Time Complexity: O(n 2 ) For each item, make (n –1) comparisons Gives: Comparisons = (n –1) + (n – 2)
Chapter 9: Sorting1 Sorting & Searching Ch. # 9. Chapter 9: Sorting2 Chapter Outline  What is sorting and complexity of sorting  Different types of.
Sorting & Searching Geletaw S (MSC, MCITP). Objectives At the end of this session the students should be able to: – Design and implement the following.
Data Structures and Algorithms Instructor: Tesfaye Guta [M.Sc.] Haramaya University.
SORTING Chapter 8. Chapter Objectives  To learn how to use the standard sorting methods in the Java API  To learn how to implement the following sorting.
Chapter 16: Searching, Sorting, and the vector Type.
Chapter 11 Sorting Algorithms and their Efficiency
Design and Analysis of Algorithms
Description Given a linear collection of items x1, x2, x3,….,xn
Sorting means The values stored in an array have keys of a type for which the relational operators are defined. (We also assume unique keys.) Sorting.
Chapter 10 Sorting and Searching Algorithms
Sorting Algorithms.
CS Data Structures Chapter 17 Heaps Mehmet H Gunes
C++ Plus Data Structures
Yan Shi CS/SE 2630 Lecture Notes
Sub-Quadratic Sorting Algorithms
Chapter 10 Sorting Algorithms
Sorting Algorithms.
Searching/Sorting/Searching
Presentation transcript:

1 Sorting/Searching CS308 Data Structures

2 Sorting means... l Sorting rearranges the elements into either ascending or descending order within the array. (we’ll use ascending order.)

3 Divides the array into two parts: already sorted, and not yet sorted. On each pass, finds the smallest of the unsorted elements, and swaps it into its correct place, thereby increasing the number of sorted elements by one. Straight Selection Sort values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

4 Selection Sort: Pass One values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED

5 Selection Sort: End Pass One values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

6 Selection Sort: Pass Two values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED

7 Selection Sort: End Pass Two values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

8 Selection Sort: Pass Three values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

9 Selection Sort: End Pass Three values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTEDSORTED UNSORTED

10 Selection Sort: Pass Four values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTEDSORTED UNSORTED

11 Selection Sort: End Pass Four values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTEDSORTED

12 Selection Sort: How many comparisons? values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] compares for values[0] 3 compares for values[1] 2 compares for values[2] 1 compare for values[3] =

13 For selection sort in general l The number of comparisons when the array contains N elements is Sum = (N-1) + (N-2) (arithmetic series) O(N 2 )

template void SelectionSort ( ItemType values [ ], int numValues ) // Post: Sorts array values[0.. numValues-1 ] into ascending // order by key { int endIndex = numValues - 1 ; for ( int current = 0 ; current < endIndex ; current++ ) Swap ( values [ current ], values [ MinIndex ( values, current, endIndex ) ] ) ; } 14

template int MinIndex ( ItemType values [ ], int start, int end ) // Post: Function value = index of the smallest value in // values [start].. values [end]. { int indexOfMin = start ; for ( int index = start + 1 ; index <= end ; index++ ) if ( values [ index ] < values [ indexOfMin ] ) indexOfMin = index ; return indexOfMin; } 15

16 Compares neighboring pairs of array elements, starting with the last array element, and swaps neighbors whenever they are not in correct order. On each pass, this causes the smallest element to “bubble up” to its correct place in the array. Bubble Sort values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

17 Bubble Sort: Pass One values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED

18 Bubble Sort: Pass One values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED

19 Bubble Sort: Pass One values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED

20 Bubble Sort: Pass One values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED

21 Bubble Sort: End Pass One values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

22 Bubble Sort: Pass Two values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

23 Bubble Sort: Pass Two values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

24 Bubble Sort: Pass Two values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

25 Bubble Sort: End Pass Two values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

26 Bubble Sort: Pass Three values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

27 Bubble Sort: Pass Three values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

28 Bubble Sort: End Pass Three values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTED SORTEDSORTED

29 Bubble Sort: Pass Four values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTED SORTEDSORTED

30 Bubble Sort: End Pass Four values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTEDSORTED

template void BubbleUp ( ItemType values [ ], int start, int end ) // Post: Neighboring elements that were out of order have been // swapped between values [start] and values [end], // beginning at values [end]. { for ( int index = end ; index > start ; index-- ) if (values [ index ] < values [ index - 1 ] ) Swap ( values [ index ], values [ index - 1 ] ) ; } 31

template void BubbleSort ( ItemType values [ ], int numValues ) // Post: Sorts array values[0.. numValues-1 ] into ascending // order by key { int current = 0 ; while ( current < numValues - 1 ) BubbleUp ( values, current, numValues - 1 ) ; current++ ; } 32

33 One by one, each as yet unsorted array element is inserted into its proper place with respect to the already sorted elements. On each pass, this causes the number of already sorted elements to increase by one. Insertion Sort values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

34 Works like someone who “inserts” one more card at a time into a hand of cards that are already sorted. To insert 12, we need to make room for it by moving first 36 and then 24. Insertion Sort

Works like someone who “inserts” one more card at a time into a hand of cards that are already sorted. To insert 12, we need to make room for it by moving first 36 and then 24. Insertion Sort 36 12

36 Works like someone who “inserts” one more card at a time into a hand of cards that are already sorted. To insert 12, we need to make room for it by moving first 36 and then 24. Insertion Sort

37 Works like someone who “inserts” one more card at a time into a hand of cards that are already sorted. To insert 12, we need to make room for it by moving first 36 and then 24. Insertion Sort

38 Insertion Sort: Pass One values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTED UNSORTEDUNSORTED

39 Insertion Sort: Pass Two values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTEDUNSORTED SORTED

40 Insertion Sort: Pass Three values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] UNSORTED SORTEDSORTED

41 Insertion Sort: Pass Four values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTEDSORTED UNSORTED

42 Insertion Sort: Pass Five values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTEDSORTED

Sorting Algorithms and Average Case Number of Comparisons Simple Sorts n Straight Selection Sort n Bubble Sort n Insertion Sort More Complex Sorts n Quick Sort n Merge Sort n Heap Sort O(N 2 ) O(N*log N) 43

44 Heap Sort Approach First, make the unsorted array into a heap by satisfying the order property. Then repeat the steps below until there are no more unsorted elements. l Take the root (maximum) element off the heap by swapping it into its correct place in the array at the end of the unsorted elements. l Reheap the remaining unsorted elements. (This puts the next-largest element into the root position).

45 After creating the original heap [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root 10 6

46 Swap root element into last place in unsorted array [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root 10 6

47 After swapping root element into its place [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root NO NEED TO CONSIDER AGAIN

48 After reheaping remaining unsorted elements [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root

49 Swap root element into last place in unsorted array [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root

50 After swapping root element into its place [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root NO NEED TO CONSIDER AGAIN 60 5

51 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root After reheaping remaining unsorted elements

52 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root Swap root element into last place in unsorted array

53 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root After swapping root element into its place NO NEED TO CONSIDER AGAIN

54 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root After reheaping remaining unsorted elements

55 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root Swap root element into last place in unsorted array

56 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root After swapping root element into its place NO NEED TO CONSIDER AGAIN

57 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root After reheaping remaining unsorted elements

58 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root Swap root element into last place in unsorted array

59 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root After swapping root element into its place NO NEED TO CONSIDER AGAIN

60 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root After reheaping remaining unsorted elements

61 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root Swap root element into last place in unsorted array

62 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] values root After swapping root element into its place ALL ELEMENTS ARE SORTED

template void HeapSort ( ItemType values [ ], int numValues ) // Post: Sorts array values[ 0.. numValues-1 ] into ascending // order by key { int index ; // Convert array values[ 0.. numValues-1 ] into a heap. for ( index = numValues/2 - 1 ; index >= 0 ; index-- ) ReheapDown ( values, index, numValues - 1 ) ; // Sort the array. for ( index = numValues - 1 ; index >= 1 ; index-- ) { Swap ( values [0], values [index] ); ReheapDown ( values, 0, index - 1 ) ; } 63

64 Heap Sort: How many comparisons? root In reheap down, an element is compared with its 2 children (and swapped with the larger). But only one element at each level makes this comparison, and a complete binary tree with N nodes has only O(log 2 N) levels

65 Heap Sort of N elements: How many comparisons? (N/2) * O(log N) compares to create original heap (N-1) * O(log N) compares for the sorting loop = O ( N * log N) compares total

66 Using quick sort algorithm A.. Z A.. L M.. Z A.. F G.. L M.. R S.. Z

// Recursive quick sort algorithm template void QuickSort ( ItemType values[ ], int first, int last ) // Pre: first <= last // Post: Sorts array values[ first.. last ] into ascending order { if ( first < last ) // general case {int splitPoint ; Split ( values, first, last, splitPoint ) ; // values [ first ].. values[splitPoint - 1 ] <= splitVal // values [ splitPoint ] = splitVal // values [ splitPoint + 1 ].. values[ last ] > splitVal QuickSort( values, first, splitPoint - 1 ) ; QuickSort( values, splitPoint + 1, last ); } } ; 67

68 Before call to function Split values[first] [last] splitVal = 9 GOAL: place splitVal in its proper position with all values less than or equal to splitVal on its left and all larger values on its right

69 After call to function Split values[first] [last] splitVal = 9 smaller values larger values in left part in right part splitVal in correct position

70 Quick Sort of N elements: How many comparisons? N For first call, when each of N elements is compared to the split value 2 * N/2 For the next pair of calls, when N/2 elements in each “half” of the original array are compared to their own split values. 4 * N/4For the four calls when N/4 elements in each “quarter” of original array are compared to their own split values... HOW MANY SPLITS CAN OCCUR?

71 Quick Sort of N elements: How many splits can occur? It depends on the order of the original array elements! If each split divides the subarray approximately in half, there will be only log 2 N splits, and QuickSort is O(N*log 2 N). But, if the original array was sorted to begin with, the recursive calls will split up the array into parts of unequal length, with one part empty, and the other part containing all the rest of the array except for split value itself. In this case, there can be as many as N-1 splits, and QuickSort is O(N 2 ).

72 Before call to function Split values[first] [last] splitVal = 9 GOAL: place splitVal in its proper position with all values less than or equal to splitVal on its left and all larger values on its right

73 After call to function Split values[first] [last] splitVal in correct position splitVal = 9 no smaller values larger values empty left part in right part with N-1 elements

74 Merge Sort Algorithm Cut the array in half. Sort the left half. Sort the right half. Merge the two sorted halves into one sorted array. [first] [middle] [middle + 1] [last]

// Recursive merge sort algorithm template void MergeSort ( ItemType values[ ], int first, int last ) // Pre: first <= last // Post: Array values[ first.. last ] sorted into ascending order. { if ( first < last ) // general case {int middle = ( first + last ) / 2 ; MergeSort ( values, first, middle ) ; MergeSort( values, middle + 1, last ) ; // now merge two subarrays // values [ first... middle ] with // values [ middle + 1,... last ]. Merge( values, first, middle, middle + 1, last ) ; } 75

76 Using Merge Sort Algorithm with N =

77 Merge Sort of N elements: How many comparisons? The entire array can be subdivided into halves only log 2 N times. Each time it is subdivided, function Merge is called to re-combine the halves. Function Merge uses a temporary array to store the merged elements. Merging is O(N) because it compares each element in the subarrays. Copying elements back from the temporary array to the values array is also O(N). MERGE SORT IS O(N*log 2 N).

78 Hashing l is a means used to order and access elements in a list quickly -- the goal is O(1) time -- by using a function of the key value to identify its location in the list. l The function of the key value is called a hash function. FOR EXAMPLE...

79 Using a hash function [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]. Empty 4501 Empty values [ 97] [ 98] [ 99] 7803 Empty. Empty HandyParts company makes no more than 100 different parts. But the parts all have four digit numbers. This hash function can be used to store and retrieve parts in an array. Hash(key) = partNum % 100

80 Placing elements in the array Use the hash function Hash(key) = partNum % 100 to place the element with part number 5502 in the array. [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]. Empty 4501 Empty values [ 97] [ 98] [ 99] 7803 Empty. Empty

81 Placing elements in the array Next place part number 6702 in the array. Hash(key) = partNum % % 100 = 2 But values[2] is already occupied. COLLISION OCCURS [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]. values [ 97] [ 98] [ 99] 7803 Empty. Empty Empty

82 How to resolve the collision? One way is by linear probing. This uses the rehash function (HashValue + 1) % 100 repeatedly until an empty location is found for part number [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]. values [ 97] [ 98] [ 99] 7803 Empty. Empty Empty

83 Resolving the collision Still looking for a place for 6702 using the function (HashValue + 1) % 100 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]. values [ 97] [ 98] [ 99] 7803 Empty. Empty Empty

84 Collision resolved Part 6702 can be placed at the location with index 4. [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]. values [ 97] [ 98] [ 99] 7803 Empty. Empty Empty

85 Collision resolved Part 6702 is placed at the location with index 4. Where would the part with number 4598 be placed using linear probing? [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]. values [ 97] [ 98] [ 99] Empty Empty