SlideShare a Scribd company logo
1 of 25
UNIT 5
SEARCHING & SORTING
SEARCHING
 Searching is the process of determining whether or
not a given value exists in a data structure or a
storage media.
 linear search and binary search.
LINEAR SEARCH
 The linear (or sequential) search algorithm on an
array is:
 Sequentially scan the array, comparing each array item with the searched
value.
 If a match is found; return the index of the matched element; otherwise
return –1.
 Note: linear search can be applied to both sorted and
unsorted arrays.
FEATURES OF LINEAR SEARCH
 It is used for unsorted and unordered small list of
elements.
 It has a time complexity of O(n), which means the
time is linearly dependent on the number of
elements, which is not bad, but not that good too.
 It has a very simple implementation.
APPLICATIONS OF LINEAR SEARCH
 Used to find the desired element from the collection
of data when the dataset is small
 The searching operations is less than 100 items
BINARY SEARCH
 An algorithm to solve this task looks at the
middle of the array or array segment first
 If the value looked for is smaller than the
value in the middle of the array
 Then the second half of the array or array
segment can be ignored
 This strategy is then applied to the first half of the
array or array segment
BINARY SEARCH (CONT.,)
 If the value looked for is larger than the value in the
middle of the array or array segment
 Then the first half of the array or array segment can be
ignored
 This strategy is then applied to the second half of the array
or array segment
 If the value looked for is at the middle of the array
or array segment, then it has been found
 If the entire array (or array segment) has been
searched in this way without finding the value, then
it is not in the array
EFFICIENCY OF BINARY SEARCH
 The binary search algorithm is extremely fast
compared to an algorithm that tries all array
elements in order
 About half the array is eliminated from consideration
right at the start
 Then a quarter of the array, then an eighth of the array,
and so forth
APPLICATIONS OF BINARY SEARCH
 The binary search algorithm is used in the libraries
of Java, C++, etc
 It is used in another additional program like finding
the smallest element or largest element in the array
 It is used to implement a dictionary
SORTING METHODS
 Sorting Algorithms are methods of reorganizing a
large number of items into some specific order such
as highest to lowest, or vice-versa, or even in some
alphabetical order.
 These algorithms take an input list, processes it
(i.e, performs some operations on it) and produce
the sorted list.
 The most common example we experience every
day is sorting clothes or other items on an e-
commerce website either by lowest-price to highest,
or list by popularity, or some other order.
TYPES OF SORTING ALGORITHMS
 Shell sort
 Heap sort
 Radix sort
 Bucket sort
 Quick sort
 Bubble sort
 Merge sort
 Insertion sort
 Selection sort
BUBBLE SORT
 Bubble sort, also referred to as comparison sort
 It is a simple sorting algorithm that repeatedly goes
through the list, compares adjacent elements and
swaps them if they are in the wrong order.
 This is the most simplest algorithm and inefficient at
the same time.
 https://www.interviewbit.com/tutorial/bubble-sort/
SELECTION SORT
 Selection sort is a simple comparison-based sorting
algorithm
 Steps to be followed
 Pick the minimum element from the unsorted
subarray.
 Swap it with the leftmost element of the unsorted
subarray.
 Now the leftmost element of unsorted subarray
becomes a part (rightmost) of sorted subarray and
will not be a part of unsorted subarray.
https://www.interviewbit.com/tutorial/selection-sort/
INSERTION SORT
 Insertion sort is the sorting mechanism where the
sorted array is built having one item at a time.
 The array elements are compared with each other
sequentially and then arranged simultaneously in
some particular order.
 This sort works on the principle of inserting an
element at a particular position, hence the name
Insertion Sort.
 https://www.interviewbit.com/tutorial/insertion-sort-
algorithm/
SHELL SORT
 Shell sort is a highly efficient sorting algorithm and is
based on insertion sort algorithm.
 This algorithm avoids large shifts as in case of insertion
sort, if the smaller value is to the far right and has to be
moved to the far left.
 Steps to be followed
 Step 1 − Initialize the value of h.
 Step 2 − Divide the list into smaller sub-list of equal
interval h.
 Step 3 − Sort these sub-lists using insertion sort.
 Step 3 − Repeat until complete list is sorted.
 https://www.tutorialspoint.com/data_structures_algorith
ms/shell_sort_algorithm.htm
RADIX SORT
 Radix sort is one of the sorting algorithms used
to sort a list of integer numbers in order.
 In radix sort algorithm, a list of integer numbers will
be sorted based on the digits of individual numbers.
 Sorting is performed from least significant digit to
the most significant digit.
QUICK SORT
 It is one of the most efficient sorting algorithms and
is based on the splitting of an array (partition) into
smaller ones and swapping (exchange) based on
the comparison with 'pivot' element selected.
 Due to this, quick sort is also called as "Partition
Exchange" sort.
 Steps to be followed:
 Step 1 − Make any element as pivot
Step 2 − Partition the array on the basis of pivot
Step 3 − Apply quick sort on left partition
recursively
Step 4 − Apply quick sort on right partition
recursively
HEAP SORT
 Heap sort is a comparison-based sorting
technique based on Binary Heap data structure
 https://www.youtube.com/watch?v=MtQL_ll5KhQ
 There are two kinds of heaps: min-heap and max-
heap.
 In min-heap parents nodes are smaller than
children nodes (the root node is smallest), while in
max-heap it is opposite (the root node is largest).
MERGE SORT
 Merge sort is one of the most efficient sorting
algorithms. It works on the principle of Divide and
Conquer.
 Merge sort repeatedly breaks down a list into
several sublists until each sublist consists of a
single element and merging those sublists in a
manner that results into a sorted list.
 https://www.interviewbit.com/tutorial/merge-sort-
algorithm/
COMPARISON OF SORTING ALOGORITHMS
 In a comparison based sorting algorithms, we
compare elements of an array with each other to
determines which of two elements should occur first
in the final sorted list.
 All comparison-based sorting algorithms have a
complexity lower bound of nlogn.
Searching,sorting

More Related Content

What's hot

Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm03446940736
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin RamolaDipayan Sarkar
 
Sorting Techniques
Sorting TechniquesSorting Techniques
Sorting TechniquesRafay Farooq
 
Searching Techniques and Analysis
Searching Techniques and AnalysisSearching Techniques and Analysis
Searching Techniques and AnalysisAkashBorse2
 
Queue_Data_Structure.pptx
Queue_Data_Structure.pptxQueue_Data_Structure.pptx
Queue_Data_Structure.pptxsandeep54552
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | EdurekaEdureka!
 
3.2 insertion sort
3.2 insertion sort3.2 insertion sort
3.2 insertion sortKrish_ver2
 
Bubble sort | Data structure |
Bubble sort | Data structure |Bubble sort | Data structure |
Bubble sort | Data structure |MdSaiful14
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structuresDurgaDeviCbit
 
SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptxDr.Shweta
 
List Data Structure
List Data StructureList Data Structure
List Data StructureZidny Nafan
 
Binary Search Algorithm.pptx
Binary Search Algorithm.pptxBinary Search Algorithm.pptx
Binary Search Algorithm.pptxBhagyashreeMadan1
 

What's hot (20)

Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin Ramola
 
Sorting Techniques
Sorting TechniquesSorting Techniques
Sorting Techniques
 
Searching Techniques and Analysis
Searching Techniques and AnalysisSearching Techniques and Analysis
Searching Techniques and Analysis
 
Queue_Data_Structure.pptx
Queue_Data_Structure.pptxQueue_Data_Structure.pptx
Queue_Data_Structure.pptx
 
Binary search
Binary searchBinary search
Binary search
 
Merge sort
Merge sortMerge sort
Merge sort
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | Edureka
 
3.2 insertion sort
3.2 insertion sort3.2 insertion sort
3.2 insertion sort
 
Insertion Sort
Insertion SortInsertion Sort
Insertion Sort
 
Bubble sort | Data structure |
Bubble sort | Data structure |Bubble sort | Data structure |
Bubble sort | Data structure |
 
binary search tree
binary search treebinary search tree
binary search tree
 
Searching algorithm
Searching algorithmSearching algorithm
Searching algorithm
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
Linked list
Linked list Linked list
Linked list
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptx
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
 
Binary Search Algorithm.pptx
Binary Search Algorithm.pptxBinary Search Algorithm.pptx
Binary Search Algorithm.pptx
 

Similar to Searching,sorting

DS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxDS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxprakashvs7
 
Data Structures_ Sorting & Searching
Data Structures_ Sorting & SearchingData Structures_ Sorting & Searching
Data Structures_ Sorting & SearchingThenmozhiK5
 
What is a Sorting Algorithm Ishank mini project.pptx
What is a Sorting Algorithm Ishank mini project.pptxWhat is a Sorting Algorithm Ishank mini project.pptx
What is a Sorting Algorithm Ishank mini project.pptxSneakyGoblin1
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHISowmya Jyothi
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal searchKrish_ver2
 
Algorithm 8th lecture linear & binary search(2).pptx
Algorithm 8th lecture linear & binary search(2).pptxAlgorithm 8th lecture linear & binary search(2).pptx
Algorithm 8th lecture linear & binary search(2).pptxAftabali702240
 
advanced searching and sorting.pdf
advanced searching and sorting.pdfadvanced searching and sorting.pdf
advanced searching and sorting.pdfharamaya university
 
Sorting algorithms in Data Structure
Sorting algorithms in Data StructureSorting algorithms in Data Structure
Sorting algorithms in Data StructureBalamurugan M
 
Ijcse13 05-01-048
Ijcse13 05-01-048Ijcse13 05-01-048
Ijcse13 05-01-048vital vital
 
Ijcse13 05-01-048
Ijcse13 05-01-048Ijcse13 05-01-048
Ijcse13 05-01-048vital vital
 
Data Structure & Algorithms - Operations
Data Structure & Algorithms - OperationsData Structure & Algorithms - Operations
Data Structure & Algorithms - Operationsbabuk110
 
data_structure_Chapter two_computer.pptx
data_structure_Chapter two_computer.pptxdata_structure_Chapter two_computer.pptx
data_structure_Chapter two_computer.pptxMohammed472103
 

Similar to Searching,sorting (20)

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
 
What is a Sorting Algorithm Ishank mini project.pptx
What is a Sorting Algorithm Ishank mini project.pptxWhat is a Sorting Algorithm Ishank mini project.pptx
What is a Sorting Algorithm Ishank mini project.pptx
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal search
 
Unit v data structure-converted
Unit  v data structure-convertedUnit  v data structure-converted
Unit v data structure-converted
 
Sorting.pptx
Sorting.pptxSorting.pptx
Sorting.pptx
 
Algorithm 8th lecture linear & binary search(2).pptx
Algorithm 8th lecture linear & binary search(2).pptxAlgorithm 8th lecture linear & binary search(2).pptx
Algorithm 8th lecture linear & binary search(2).pptx
 
arrays in c
arrays in carrays in c
arrays in c
 
advanced searching and sorting.pdf
advanced searching and sorting.pdfadvanced searching and sorting.pdf
advanced searching and sorting.pdf
 
Analysis of Algorithm - Binary Search.pptx
Analysis of Algorithm - Binary Search.pptxAnalysis of Algorithm - Binary Search.pptx
Analysis of Algorithm - Binary Search.pptx
 
Sorting algorithms in Data Structure
Sorting algorithms in Data StructureSorting algorithms in Data Structure
Sorting algorithms in Data Structure
 
cs702 ppt.ppt
cs702 ppt.pptcs702 ppt.ppt
cs702 ppt.ppt
 
Sorting
SortingSorting
Sorting
 
Searching and sorting
Searching  and sortingSearching  and sorting
Searching and sorting
 
Ijcse13 05-01-048
Ijcse13 05-01-048Ijcse13 05-01-048
Ijcse13 05-01-048
 
Ijcse13 05-01-048
Ijcse13 05-01-048Ijcse13 05-01-048
Ijcse13 05-01-048
 
Data Structure & Algorithms - Operations
Data Structure & Algorithms - OperationsData Structure & Algorithms - Operations
Data Structure & Algorithms - Operations
 
data_structure_Chapter two_computer.pptx
data_structure_Chapter two_computer.pptxdata_structure_Chapter two_computer.pptx
data_structure_Chapter two_computer.pptx
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 

More from LavanyaJ28

Cs1301 syllabus
Cs1301  syllabusCs1301  syllabus
Cs1301 syllabusLavanyaJ28
 
Ds important questions
Ds important questionsDs important questions
Ds important questionsLavanyaJ28
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using pythonLavanyaJ28
 
Heap types & Trees
Heap types & TreesHeap types & Trees
Heap types & TreesLavanyaJ28
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures LavanyaJ28
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures LavanyaJ28
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack LavanyaJ28
 
Stack and queue
Stack and queueStack and queue
Stack and queueLavanyaJ28
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked listLavanyaJ28
 
Unit 1 Basic concepts to DS
Unit 1 Basic concepts to DSUnit 1 Basic concepts to DS
Unit 1 Basic concepts to DSLavanyaJ28
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementationLavanyaJ28
 
Unit 1 polynomial manipulation
Unit 1   polynomial manipulationUnit 1   polynomial manipulation
Unit 1 polynomial manipulationLavanyaJ28
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data typesLavanyaJ28
 

More from LavanyaJ28 (16)

Cs1301 syllabus
Cs1301  syllabusCs1301  syllabus
Cs1301 syllabus
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
 
Hashing
HashingHashing
Hashing
 
Graphs
GraphsGraphs
Graphs
 
Unit 3 trees
Unit 3   treesUnit 3   trees
Unit 3 trees
 
Heap types & Trees
Heap types & TreesHeap types & Trees
Heap types & Trees
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
 
Unit 1 Basic concepts to DS
Unit 1 Basic concepts to DSUnit 1 Basic concepts to DS
Unit 1 Basic concepts to DS
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementation
 
Unit 1 polynomial manipulation
Unit 1   polynomial manipulationUnit 1   polynomial manipulation
Unit 1 polynomial manipulation
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data types
 

Recently uploaded

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 

Searching,sorting

  • 2. SEARCHING  Searching is the process of determining whether or not a given value exists in a data structure or a storage media.  linear search and binary search.
  • 3. LINEAR SEARCH  The linear (or sequential) search algorithm on an array is:  Sequentially scan the array, comparing each array item with the searched value.  If a match is found; return the index of the matched element; otherwise return –1.  Note: linear search can be applied to both sorted and unsorted arrays.
  • 4. FEATURES OF LINEAR SEARCH  It is used for unsorted and unordered small list of elements.  It has a time complexity of O(n), which means the time is linearly dependent on the number of elements, which is not bad, but not that good too.  It has a very simple implementation.
  • 5.
  • 6. APPLICATIONS OF LINEAR SEARCH  Used to find the desired element from the collection of data when the dataset is small  The searching operations is less than 100 items
  • 7. BINARY SEARCH  An algorithm to solve this task looks at the middle of the array or array segment first  If the value looked for is smaller than the value in the middle of the array  Then the second half of the array or array segment can be ignored  This strategy is then applied to the first half of the array or array segment
  • 8. BINARY SEARCH (CONT.,)  If the value looked for is larger than the value in the middle of the array or array segment  Then the first half of the array or array segment can be ignored  This strategy is then applied to the second half of the array or array segment  If the value looked for is at the middle of the array or array segment, then it has been found  If the entire array (or array segment) has been searched in this way without finding the value, then it is not in the array
  • 9. EFFICIENCY OF BINARY SEARCH  The binary search algorithm is extremely fast compared to an algorithm that tries all array elements in order  About half the array is eliminated from consideration right at the start  Then a quarter of the array, then an eighth of the array, and so forth
  • 10.
  • 11. APPLICATIONS OF BINARY SEARCH  The binary search algorithm is used in the libraries of Java, C++, etc  It is used in another additional program like finding the smallest element or largest element in the array  It is used to implement a dictionary
  • 12. SORTING METHODS  Sorting Algorithms are methods of reorganizing a large number of items into some specific order such as highest to lowest, or vice-versa, or even in some alphabetical order.  These algorithms take an input list, processes it (i.e, performs some operations on it) and produce the sorted list.  The most common example we experience every day is sorting clothes or other items on an e- commerce website either by lowest-price to highest, or list by popularity, or some other order.
  • 13. TYPES OF SORTING ALGORITHMS  Shell sort  Heap sort  Radix sort  Bucket sort  Quick sort  Bubble sort  Merge sort  Insertion sort  Selection sort
  • 14. BUBBLE SORT  Bubble sort, also referred to as comparison sort  It is a simple sorting algorithm that repeatedly goes through the list, compares adjacent elements and swaps them if they are in the wrong order.  This is the most simplest algorithm and inefficient at the same time.  https://www.interviewbit.com/tutorial/bubble-sort/
  • 15. SELECTION SORT  Selection sort is a simple comparison-based sorting algorithm  Steps to be followed  Pick the minimum element from the unsorted subarray.  Swap it with the leftmost element of the unsorted subarray.  Now the leftmost element of unsorted subarray becomes a part (rightmost) of sorted subarray and will not be a part of unsorted subarray. https://www.interviewbit.com/tutorial/selection-sort/
  • 16. INSERTION SORT  Insertion sort is the sorting mechanism where the sorted array is built having one item at a time.  The array elements are compared with each other sequentially and then arranged simultaneously in some particular order.  This sort works on the principle of inserting an element at a particular position, hence the name Insertion Sort.  https://www.interviewbit.com/tutorial/insertion-sort- algorithm/
  • 17. SHELL SORT  Shell sort is a highly efficient sorting algorithm and is based on insertion sort algorithm.  This algorithm avoids large shifts as in case of insertion sort, if the smaller value is to the far right and has to be moved to the far left.  Steps to be followed  Step 1 − Initialize the value of h.  Step 2 − Divide the list into smaller sub-list of equal interval h.  Step 3 − Sort these sub-lists using insertion sort.  Step 3 − Repeat until complete list is sorted.  https://www.tutorialspoint.com/data_structures_algorith ms/shell_sort_algorithm.htm
  • 18. RADIX SORT  Radix sort is one of the sorting algorithms used to sort a list of integer numbers in order.  In radix sort algorithm, a list of integer numbers will be sorted based on the digits of individual numbers.  Sorting is performed from least significant digit to the most significant digit.
  • 19.
  • 20. QUICK SORT  It is one of the most efficient sorting algorithms and is based on the splitting of an array (partition) into smaller ones and swapping (exchange) based on the comparison with 'pivot' element selected.  Due to this, quick sort is also called as "Partition Exchange" sort.  Steps to be followed:  Step 1 − Make any element as pivot Step 2 − Partition the array on the basis of pivot Step 3 − Apply quick sort on left partition recursively Step 4 − Apply quick sort on right partition recursively
  • 21.
  • 22. HEAP SORT  Heap sort is a comparison-based sorting technique based on Binary Heap data structure  https://www.youtube.com/watch?v=MtQL_ll5KhQ  There are two kinds of heaps: min-heap and max- heap.  In min-heap parents nodes are smaller than children nodes (the root node is smallest), while in max-heap it is opposite (the root node is largest).
  • 23. MERGE SORT  Merge sort is one of the most efficient sorting algorithms. It works on the principle of Divide and Conquer.  Merge sort repeatedly breaks down a list into several sublists until each sublist consists of a single element and merging those sublists in a manner that results into a sorted list.  https://www.interviewbit.com/tutorial/merge-sort- algorithm/
  • 24. COMPARISON OF SORTING ALOGORITHMS  In a comparison based sorting algorithms, we compare elements of an array with each other to determines which of two elements should occur first in the final sorted list.  All comparison-based sorting algorithms have a complexity lower bound of nlogn.