SlideShare uma empresa Scribd logo
1 de 24
Explain The Operation And
Performance Of Sorting
And Search Algorithms
By: J. Anusdika
1
By: J.Anusdika
11
Content
• Introduction
• What is sorting?
• What is searching?
• Type of sorting algorithms
• Search algorithms
•
•
•
By: J. Anusdika 2
By: J.Anusdika
22
Introduction
• Algorithm analysis should begin with a clear statement of the task to be performed.
• This allows us both to check that the algorithm is correct and to ensure that the algorithms we
are comparing perform the same task.
• Although there are many ways that algorithms can be compared, we will focus on two that are
of primary importance to many data processing algorithms:
o Time complexity: how the number of steps required depends on the size of the
input
o Space complexity: how the amount of extra memory or storage required depends
on the size of the input.
By: J. Anusdika 3
By: J.Anusdika
33
Sorting
• Sorting refers to arranging data in a particular format. Sorting algorithm specifies the way to
arrange data in a particular order. Most common orders are in numerical or lexicographical
order.
• The importance of sorting lies in the fact that data searching can be optimized to a very high
level, if data is stored in a sorted manner.
• Sorting is also used to represent data in more readable formats.
• Following are some of the examples of sorting in real-life scenarios:
§ Telephone Directory − The telephone directory stores the telephone numbers of
people sorted by their names, so that the names can be searched easily.
§ Dictionary − The dictionary stores words in an alphabetical order so that searching of
any word becomes easy.
By: J.Anusdika
44
Searching
• To finding out whether a particular element is present in the list.
• 2 methods: linear search, binary search
• The method we use depends on how the elements of the list are organized
o unordered list : linear search: simple, slow
o an ordered list : binary search or linear search: complex, faster
By: J.Anusdika
55
M3.4: Demonstrate the all available sort and search
generation methods
By: J.Anusdika
66
Type of Sorting Algorithms
• Bucket sort
• Bubble sort
• Insertion sort
• Selection sort
• Heap sort
• Merge sort
By: J.Anusdika
77
Bubble Sort
• Bubble sort is a simple and well-known sorting algorithm.
• It is used in practice once in a blue moon and its main application is to make an
introduction to the sorting algorithms.
• Bubble sort is stable and adaptive.
• Algorithm
qCompare each pair of adjacent elements from the beginning of an
array and, if they are in reversed order, swap them.
qIf at least one swap has been done, repeat step 1.
•
By: J.Anusdika
88
• Example. Sort {5, 1, 3} using bubble sort.
•
•
• Unsorted
• 5 > 1, Swap
• 5 > 3, Swap
•
• Sorted
5 1 3
5 1 3
5 31
1 3 5
By: J.Anusdika
99
Bucket Sort
• Bucket sort it’s the perfect sorting algorithm for the sequence above.
• We must know in advance that the integers are fairly well distributed over an
interval. Then we can divide this interval in N equal sub-intervals.
• We’ll put each number in its corresponding bucket.
• Finally for every bucket that contains more than one number we’ll use some
linear sorting algorithm.
By: J.Anusdika
1010
• Example:
•
•
2 3 3 1 2 4
1 2 3 4
2 3
By: J.Anusdika
1111
Insertion Sort
• This is an in-place comparison-based sorting algorithm. Here, a sub-list is
maintained which is always sorted.
• An element which is to be 'inserted in this sorted sub-list, has to find its
appropriate place and then it has to be inserted there. Hence the name,
insertion sort.
• The array is searched sequentially and unsorted items are moved and inserted
into the sorted sub-list (in the same array).
•
By: J.Anusdika
1212
How Insertion Sort Algorithm Works?
By: J.Anusdika
1313
Heap Sort Algorithm
• heapsort is a comparison-based sorting algorithm.
• Heapsort can be thought of as an improved selection sort: like that algorithm, it
divides its input into a sorted and an unsorted region, and it iteratively shrinks
the unsorted region by extracting the largest element and moving that to the
sorted region.
• The improvement consists of the use of a heap data structure rather than a
linear-time search to find the maximum.
By: J.Anusdika
1414
Example;
By: J.Anusdika
1515
Merge Sort
• Merge sort is a sorting technique based on divide and conquer technique. With
worst-case time complexity being Ο(n log n), it is one of the most respected
algorithms.
• Merge sort first divides the array into equal halves and then combines them in a
sorted manner.
By: J.Anusdika
1616
Linear Search
• A linear search is the basic and simple search algorithm.
• A linear search searches an element or value from an array till the desired
element or value is not found and it searches in a sequence order.
• It compares the element with all the other elements given in the list and if the
element is matched it returns the value index else it return -1.
• Linear Search is applied on the unsorted or unordered list when there are fewer
elements in a list.
By: J.Anusdika
1717
Example;
Algorithms
Linear Search ( Array A, Value x)
Step 1: Set i to 1
Step 2: if i > n then go to step 7
Step 3: if A[i] = x then go to step 6
Step 4: Set i to i + 1
Step 5: Go to Step 2
Step 6: Print Element x Found at
index i and go to step 8
Step 7: Print element not found
Step 8: Exit
By: J.Anusdika
1818
Binary Search
• Binary Search is applied on the sorted array or list.
• In binary search, we first compare the value with the elements in the middle
position of the array.
• If the value is matched, then we return the value.
• If the value is less than the middle element, then it must lie in the lower half of the
array and if it's greater than the element then it must lie in the upper half of the
array.
By: J.Anusdika
1919
Example With Implementation
• To search an element 9 from the sorted array or list.
• Code
• function findIndex(values, target)
{ return binarySearch(values, target, 0, values.length - 1); };
function binarySearch(values, target, start, end) { if (start > end) { return -1; }
var middle = Math.floor((start + end) / 2) , var value = values[middle];
if (value > target) { return binarySearch(values, target, start, middle-1); }
if (value < target) { return binarySearch(values, target, middle+1, end); }
return middle; //found! }
findIndex([2, 4, 7, 9, 13, 15], 9);
•
By: J.Anusdika
2020
Tree Search
• A Tree Search Only Works If The Data Fits Into A Tree Structure.
• The Database Starts At A Root That Goes To A Few Items, Each Of Which Goes To A
Few More Items And So On Until You Have A Tree.
Binary search tree. Lookup operation
• Search algorithm traverses the tree "in-depth", choosing appropriate way to go,
following binary search tree property and compares value of each visited node with
the one, we are looking for. Algorithm stops in two cases.
qA node with necessary value is found
qAlgorithm has no way to go
By: J.Anusdika
2121
D3.7: Draw conclusions about which one or more of
the above methods suitable for real world scenario
By: J.Anusdika
2222
Conclusion
• I can used merge sort and bubble sort for this scenario.
• Selection sort said to be better than bubble sort. So, we used bubble sort.
• Selection sort can used
qFind the smallest element, and put it to the first position.
qFind the next smallest element, and put it to the second position.
qRepeat until all elements are in the right positions.
• Bubble sort can Scan the array, swapping adjacent pair of elements if they are not in
relative order. This bubbles up the largest element to the end.
•
By: J.Anusdika
2323
Thank you
24

Mais conteúdo relacionado

Mais procurados

Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6
dplunkett
 
Ijcse13 05-01-048
Ijcse13 05-01-048Ijcse13 05-01-048
Ijcse13 05-01-048
vital vital
 
ODD EVEN BASED BINARY SEARCH
ODD EVEN BASED BINARY SEARCHODD EVEN BASED BINARY SEARCH
ODD EVEN BASED BINARY SEARCH
IAEME Publication
 

Mais procurados (20)

Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6
 
Non-Uniform Gap Distribution Library Sort
Non-Uniform Gap Distribution Library SortNon-Uniform Gap Distribution Library Sort
Non-Uniform Gap Distribution Library Sort
 
Searching,sorting
Searching,sortingSearching,sorting
Searching,sorting
 
Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary search
 
Data Structures & Algorithms
Data Structures & AlgorithmsData Structures & Algorithms
Data Structures & Algorithms
 
Binary search in ds
Binary search in dsBinary search in ds
Binary search in ds
 
Document clustering and classification
Document clustering and classification Document clustering and classification
Document clustering and classification
 
Top-K Dominating Queries on Incomplete Data with Priorities
Top-K Dominating Queries on Incomplete Data with PrioritiesTop-K Dominating Queries on Incomplete Data with Priorities
Top-K Dominating Queries on Incomplete Data with Priorities
 
Ijcse13 05-01-048
Ijcse13 05-01-048Ijcse13 05-01-048
Ijcse13 05-01-048
 
List classes
List classesList classes
List classes
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal search
 
Core Java Equals and hash code
Core Java Equals and hash codeCore Java Equals and hash code
Core Java Equals and hash code
 
Document Classification and Clustering
Document Classification and ClusteringDocument Classification and Clustering
Document Classification and Clustering
 
Csci101 lect10 algorithms_iii
Csci101 lect10 algorithms_iiiCsci101 lect10 algorithms_iii
Csci101 lect10 algorithms_iii
 
ODD EVEN BASED BINARY SEARCH
ODD EVEN BASED BINARY SEARCHODD EVEN BASED BINARY SEARCH
ODD EVEN BASED BINARY SEARCH
 
ADS Introduction
ADS IntroductionADS Introduction
ADS Introduction
 
Introduction to data structure and algorithms
Introduction to data structure and algorithmsIntroduction to data structure and algorithms
Introduction to data structure and algorithms
 
Unit 2 linear data structures
Unit 2   linear data structuresUnit 2   linear data structures
Unit 2 linear data structures
 
Lecture 01 Intro to DSA
Lecture 01 Intro to DSALecture 01 Intro to DSA
Lecture 01 Intro to DSA
 
INDEX SORT
INDEX SORTINDEX SORT
INDEX SORT
 

Semelhante a Data operatons & searching and sorting algorithms

DS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxDS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptx
prakashvs7
 
Data Structure & Algorithms - Operations
Data Structure & Algorithms - OperationsData Structure & Algorithms - Operations
Data Structure & Algorithms - Operations
babuk110
 
Algorithm & data structures lec4&5
Algorithm & data structures lec4&5Algorithm & data structures lec4&5
Algorithm & data structures lec4&5
Abdul Khan
 

Semelhante a Data operatons & searching and sorting algorithms (20)

Lecture_Oct26.pptx
Lecture_Oct26.pptxLecture_Oct26.pptx
Lecture_Oct26.pptx
 
searching techniques.pptx
searching techniques.pptxsearching techniques.pptx
searching techniques.pptx
 
unit II_2_i.pptx
unit II_2_i.pptxunit II_2_i.pptx
unit II_2_i.pptx
 
DS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxDS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptx
 
Data Structures_ Sorting & Searching
Data Structures_ Sorting & SearchingData Structures_ Sorting & Searching
Data Structures_ Sorting & Searching
 
cs702 ppt.ppt
cs702 ppt.pptcs702 ppt.ppt
cs702 ppt.ppt
 
data_structure_Chapter two_computer.pptx
data_structure_Chapter two_computer.pptxdata_structure_Chapter two_computer.pptx
data_structure_Chapter two_computer.pptx
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
 
Data Structure & Algorithms - Operations
Data Structure & Algorithms - OperationsData Structure & Algorithms - Operations
Data Structure & Algorithms - Operations
 
Binary search algorithm.pptx
Binary search  algorithm.pptxBinary search  algorithm.pptx
Binary search algorithm.pptx
 
Data Structures 8
Data Structures 8Data Structures 8
Data Structures 8
 
Searching
SearchingSearching
Searching
 
SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptx
 
Analysis of Algorithm - Binary Search.pptx
Analysis of Algorithm - Binary Search.pptxAnalysis of Algorithm - Binary Search.pptx
Analysis of Algorithm - Binary Search.pptx
 
Searching techniques
Searching techniquesSearching techniques
Searching techniques
 
Presentation
PresentationPresentation
Presentation
 
advanced searching and sorting.pdf
advanced searching and sorting.pdfadvanced searching and sorting.pdf
advanced searching and sorting.pdf
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
Algorithm & data structures lec4&5
Algorithm & data structures lec4&5Algorithm & data structures lec4&5
Algorithm & data structures lec4&5
 
Searching Algorithms for students of CS and IT using C++
Searching Algorithms for students of CS and IT using C++Searching Algorithms for students of CS and IT using C++
Searching Algorithms for students of CS and IT using C++
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Último (20)

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

Data operatons & searching and sorting algorithms

  • 1. Explain The Operation And Performance Of Sorting And Search Algorithms By: J. Anusdika 1 By: J.Anusdika 11
  • 2. Content • Introduction • What is sorting? • What is searching? • Type of sorting algorithms • Search algorithms • • • By: J. Anusdika 2 By: J.Anusdika 22
  • 3. Introduction • Algorithm analysis should begin with a clear statement of the task to be performed. • This allows us both to check that the algorithm is correct and to ensure that the algorithms we are comparing perform the same task. • Although there are many ways that algorithms can be compared, we will focus on two that are of primary importance to many data processing algorithms: o Time complexity: how the number of steps required depends on the size of the input o Space complexity: how the amount of extra memory or storage required depends on the size of the input. By: J. Anusdika 3 By: J.Anusdika 33
  • 4. Sorting • Sorting refers to arranging data in a particular format. Sorting algorithm specifies the way to arrange data in a particular order. Most common orders are in numerical or lexicographical order. • The importance of sorting lies in the fact that data searching can be optimized to a very high level, if data is stored in a sorted manner. • Sorting is also used to represent data in more readable formats. • Following are some of the examples of sorting in real-life scenarios: § Telephone Directory − The telephone directory stores the telephone numbers of people sorted by their names, so that the names can be searched easily. § Dictionary − The dictionary stores words in an alphabetical order so that searching of any word becomes easy. By: J.Anusdika 44
  • 5. Searching • To finding out whether a particular element is present in the list. • 2 methods: linear search, binary search • The method we use depends on how the elements of the list are organized o unordered list : linear search: simple, slow o an ordered list : binary search or linear search: complex, faster By: J.Anusdika 55
  • 6. M3.4: Demonstrate the all available sort and search generation methods By: J.Anusdika 66
  • 7. Type of Sorting Algorithms • Bucket sort • Bubble sort • Insertion sort • Selection sort • Heap sort • Merge sort By: J.Anusdika 77
  • 8. Bubble Sort • Bubble sort is a simple and well-known sorting algorithm. • It is used in practice once in a blue moon and its main application is to make an introduction to the sorting algorithms. • Bubble sort is stable and adaptive. • Algorithm qCompare each pair of adjacent elements from the beginning of an array and, if they are in reversed order, swap them. qIf at least one swap has been done, repeat step 1. • By: J.Anusdika 88
  • 9. • Example. Sort {5, 1, 3} using bubble sort. • • • Unsorted • 5 > 1, Swap • 5 > 3, Swap • • Sorted 5 1 3 5 1 3 5 31 1 3 5 By: J.Anusdika 99
  • 10. Bucket Sort • Bucket sort it’s the perfect sorting algorithm for the sequence above. • We must know in advance that the integers are fairly well distributed over an interval. Then we can divide this interval in N equal sub-intervals. • We’ll put each number in its corresponding bucket. • Finally for every bucket that contains more than one number we’ll use some linear sorting algorithm. By: J.Anusdika 1010
  • 11. • Example: • • 2 3 3 1 2 4 1 2 3 4 2 3 By: J.Anusdika 1111
  • 12. Insertion Sort • This is an in-place comparison-based sorting algorithm. Here, a sub-list is maintained which is always sorted. • An element which is to be 'inserted in this sorted sub-list, has to find its appropriate place and then it has to be inserted there. Hence the name, insertion sort. • The array is searched sequentially and unsorted items are moved and inserted into the sorted sub-list (in the same array). • By: J.Anusdika 1212
  • 13. How Insertion Sort Algorithm Works? By: J.Anusdika 1313
  • 14. Heap Sort Algorithm • heapsort is a comparison-based sorting algorithm. • Heapsort can be thought of as an improved selection sort: like that algorithm, it divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element and moving that to the sorted region. • The improvement consists of the use of a heap data structure rather than a linear-time search to find the maximum. By: J.Anusdika 1414
  • 16. Merge Sort • Merge sort is a sorting technique based on divide and conquer technique. With worst-case time complexity being Ο(n log n), it is one of the most respected algorithms. • Merge sort first divides the array into equal halves and then combines them in a sorted manner. By: J.Anusdika 1616
  • 17. Linear Search • A linear search is the basic and simple search algorithm. • A linear search searches an element or value from an array till the desired element or value is not found and it searches in a sequence order. • It compares the element with all the other elements given in the list and if the element is matched it returns the value index else it return -1. • Linear Search is applied on the unsorted or unordered list when there are fewer elements in a list. By: J.Anusdika 1717
  • 18. Example; Algorithms Linear Search ( Array A, Value x) Step 1: Set i to 1 Step 2: if i > n then go to step 7 Step 3: if A[i] = x then go to step 6 Step 4: Set i to i + 1 Step 5: Go to Step 2 Step 6: Print Element x Found at index i and go to step 8 Step 7: Print element not found Step 8: Exit By: J.Anusdika 1818
  • 19. Binary Search • Binary Search is applied on the sorted array or list. • In binary search, we first compare the value with the elements in the middle position of the array. • If the value is matched, then we return the value. • If the value is less than the middle element, then it must lie in the lower half of the array and if it's greater than the element then it must lie in the upper half of the array. By: J.Anusdika 1919
  • 20. Example With Implementation • To search an element 9 from the sorted array or list. • Code • function findIndex(values, target) { return binarySearch(values, target, 0, values.length - 1); }; function binarySearch(values, target, start, end) { if (start > end) { return -1; } var middle = Math.floor((start + end) / 2) , var value = values[middle]; if (value > target) { return binarySearch(values, target, start, middle-1); } if (value < target) { return binarySearch(values, target, middle+1, end); } return middle; //found! } findIndex([2, 4, 7, 9, 13, 15], 9); • By: J.Anusdika 2020
  • 21. Tree Search • A Tree Search Only Works If The Data Fits Into A Tree Structure. • The Database Starts At A Root That Goes To A Few Items, Each Of Which Goes To A Few More Items And So On Until You Have A Tree. Binary search tree. Lookup operation • Search algorithm traverses the tree "in-depth", choosing appropriate way to go, following binary search tree property and compares value of each visited node with the one, we are looking for. Algorithm stops in two cases. qA node with necessary value is found qAlgorithm has no way to go By: J.Anusdika 2121
  • 22. D3.7: Draw conclusions about which one or more of the above methods suitable for real world scenario By: J.Anusdika 2222
  • 23. Conclusion • I can used merge sort and bubble sort for this scenario. • Selection sort said to be better than bubble sort. So, we used bubble sort. • Selection sort can used qFind the smallest element, and put it to the first position. qFind the next smallest element, and put it to the second position. qRepeat until all elements are in the right positions. • Bubble sort can Scan the array, swapping adjacent pair of elements if they are not in relative order. This bubbles up the largest element to the end. • By: J.Anusdika 2323

Notas do Editor

  1. You can imagine that on every step big bubbles float to the surface and stay there. At the step, when no bubble moves, sorting stops. Let us see an example of sorting an array to make the idea of bubble sort clearer.
  2. The thing is that we know that the integers are well distributed, thus we expect that there won’t be many buckets with more than one number inside.