SlideShare a Scribd company logo
Shell Sort
&
Selection Sort
Shell Sort
Algorithm
It is a highly efficient sorting algorithm and is based
on insertion sort algorithm.
Shell Sort
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.
Uses insertion sort on a widely spread elements,
sort them and then sorts the less widely spaced
elements. This spacing is termed as interval.
Shell Sort
This interval is calculated based on Knuth's formula
(h = h * 3 +1) where − h is interval with initial
value 1
This algorithm is quite efficient for medium-sized
data sets as its average and worst case complexity
are of Ο(n), where n is the number of items.
Shell Sort
THEOREM:
 Any sorting algorithm that only swaps adjacent
elements has average time no faster than
(O(n^{2})).
 The Shell sort (named for its inventor, Donald Shell)
is an early and interesting attempt to do this.
Shell Sort
 Insertion sort is fastest when;
a) The array is nearly sorted.
b) The array contains only small number of
data items
Shell Sort
 Makes use of intrinsic strength of Insertion sort.
THEOREM:
Shell Sort
 Shell sort works well because :
a) It always deals with a small number of
elements.
b) Elements are moved a long way through
array with each swap this leaves it more
nearly sorted.
THEOREM:
Shell Sort Best Case:
Shell Sort
• The best case in the shell sort is when the
array is already sorted in the right order.
• The number of comparisons is less.
Shell Sort Worst Case:
Shell Sort
• The running time of Shell sort depends on the
choice of increment sequence.
• Pairs of increments are not necessarily relatively
prime and smaller increments can have little
effect.
Shell Sort
Example:
Shell Sort
Shell Sort
Interval Sequence:
 The sequence h1,h2,h3….ht is a sequence of
increasing integer values which will be used as a
sequence (from right to left) of interval values.
• Any sequence will work as long as it is increasing
and h1=1.
Shell Sort
• For any interval value, we all have A[i] <=A[i + h].
• An array A for which this is true is hk sorted.
• An array which is hk and is then hk-1 sorted remains
as hk sorted.
 Implementation of Shell Sort
Shell Sort
Shell Sort
Shell Sort
 Output:
Selection
Sort
Algorithm
Selection Sort
 It sorts an array by repeatedly finding the minimum
element (considering ascending order) from
unsorted part and putting it at the beginning.
 The algorithm maintains two sub-arrays in a given
array.
1) The sub-array which is already sorted.
2) Remaining sub-array which is unsorted.
Selection Sort
 It is conceptually the simplest sorting algorithm.
 It is unstable sort and at the same time it can be
also stable.
 It is unstable sort and at the same time it can be
also stable.
Selection Sort
 Idea of Selection Sort: Largest-to-Smallest
• The first element of the sorted array will be the
one with the largest value.
• Second will be the largest element of the rest of
the array.
• Third will be the largest element of the new rest of
the array (initial array without the two already
sorted elements).
Selection Sort
HOW DOES SELECTION SORT WORKS?
1ST:
Find the index of the largest element and exchange
the position with the element at the last index.
2nd:
Decrement the last index
When the array ends like this, the sorting stops.
Selection Sort
Selection Sort
Three procedures inside the selection sort:
1. Comparison, the times of comparison in a n value
array is (n(n-1))/2.
2. Value Assignment, the times of value assignment
is between 0 to 3(n-1).
3. Exchanging, the times need is between 0 to (n-1).
 Implementation of Selection Sort
Selection Sort
Selection Sort
 Output:
Selection Sort

More Related Content

What's hot (20)

Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Mohammed Hussein
 
Insertion sort
Insertion sort Insertion sort
Insertion sort
Monalisa Patel
 
Searching & Sorting Algorithms
Searching & Sorting AlgorithmsSearching & Sorting Algorithms
Searching & Sorting Algorithms
Rahul Jamwal
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)
Elavarasi K
 
Heap sort
Heap sort Heap sort
Heap sort
International Islamic University
 
Selection sort
Selection sortSelection sort
Selection sort
amna izzat
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
Rajendra Dangwal
 
Selection sort
Selection sortSelection sort
Selection sort
Jay Patel
 
Sorting Techniques
Sorting TechniquesSorting Techniques
Sorting Techniques
Rafay Farooq
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Dsa – data structure and algorithms searching
Dsa – data structure and algorithms   searchingDsa – data structure and algorithms   searching
Dsa – data structure and algorithms searching
sajinis3
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
Abdelrahman Saleh
 
Searching Techniques and Analysis
Searching Techniques and AnalysisSearching Techniques and Analysis
Searching Techniques and Analysis
AkashBorse2
 
Shell sort[1]
Shell sort[1]Shell sort[1]
Shell sort[1]
Niyati Thaker
 
Selection sort algorithm presentation, selection sort example using power point
Selection sort algorithm presentation, selection sort example using power point Selection sort algorithm presentation, selection sort example using power point
Selection sort algorithm presentation, selection sort example using power point
University of Science and Technology Chitttagong
 
Queues
QueuesQueues
Queues
Lovely Professional University
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
almaqboli
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
Shakila Mahjabin
 
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]
Muhammad Hammad Waseem
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
Meghaj Mallick
 

Similar to Shell Sort and Selection Sort Algorithm (20)

Analysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysisAnalysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysis
Radhika Talaviya
 
SHELL SORT-2.pptx
SHELL SORT-2.pptxSHELL SORT-2.pptx
SHELL SORT-2.pptx
CS50Bootcamp
 
Chapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for printChapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for print
Abdii Rashid
 
Chapter 6 - Advanced Sorting Algorithms (1).ppt
Chapter 6 - Advanced Sorting Algorithms (1).pptChapter 6 - Advanced Sorting Algorithms (1).ppt
Chapter 6 - Advanced Sorting Algorithms (1).ppt
afendimohammed288
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
IRJET Journal
 
It elective cs366-barizo-shell
It elective cs366-barizo-shellIt elective cs366-barizo-shell
It elective cs366-barizo-shell
ChristianBarizo
 
Ch2 Part III-Advanced Sorting algorithms.pptx
Ch2 Part III-Advanced Sorting algorithms.pptxCh2 Part III-Advanced Sorting algorithms.pptx
Ch2 Part III-Advanced Sorting algorithms.pptx
Mohammed472103
 
Shell sorting
Shell sortingShell sorting
Shell sorting
TUC
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptxUNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
kncetaruna
 
sorting_part1.ppt
sorting_part1.pptsorting_part1.ppt
sorting_part1.ppt
ReehaamMalikArain
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptxUNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
VISWANATHAN R V
 
358 33 powerpoint-slides_14-sorting_chapter-14
358 33 powerpoint-slides_14-sorting_chapter-14358 33 powerpoint-slides_14-sorting_chapter-14
358 33 powerpoint-slides_14-sorting_chapter-14
sumitbardhan
 
Unit vii sorting
Unit   vii sorting Unit   vii sorting
Unit vii sorting
Tribhuvan University
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
LegesseSamuel
 
Sorting Algorithms to arrange data in particular format
Sorting Algorithms to arrange data in particular formatSorting Algorithms to arrange data in particular format
Sorting Algorithms to arrange data in particular format
itsusamazahid
 
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptxDSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
suryatom5775
 
Sorting-Algorithms-A-Comprehensive-Guide.pptx
Sorting-Algorithms-A-Comprehensive-Guide.pptxSorting-Algorithms-A-Comprehensive-Guide.pptx
Sorting-Algorithms-A-Comprehensive-Guide.pptx
ReemEmad26
 
Different Searching and Sorting Methods.pptx
Different Searching and Sorting Methods.pptxDifferent Searching and Sorting Methods.pptx
Different Searching and Sorting Methods.pptx
Minakshee Patil
 
Shell sort
Shell sortShell sort
Shell sort
Rajendran
 
Shell sort by group .pptx kkjskanjkkanank
Shell sort by group .pptx kkjskanjkkanankShell sort by group .pptx kkjskanjkkanank
Shell sort by group .pptx kkjskanjkkanank
NIMONAFEKADU
 
Analysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysisAnalysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysis
Radhika Talaviya
 
Chapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for printChapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for print
Abdii Rashid
 
Chapter 6 - Advanced Sorting Algorithms (1).ppt
Chapter 6 - Advanced Sorting Algorithms (1).pptChapter 6 - Advanced Sorting Algorithms (1).ppt
Chapter 6 - Advanced Sorting Algorithms (1).ppt
afendimohammed288
 
It elective cs366-barizo-shell
It elective cs366-barizo-shellIt elective cs366-barizo-shell
It elective cs366-barizo-shell
ChristianBarizo
 
Ch2 Part III-Advanced Sorting algorithms.pptx
Ch2 Part III-Advanced Sorting algorithms.pptxCh2 Part III-Advanced Sorting algorithms.pptx
Ch2 Part III-Advanced Sorting algorithms.pptx
Mohammed472103
 
Shell sorting
Shell sortingShell sorting
Shell sorting
TUC
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptxUNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
kncetaruna
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptxUNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
VISWANATHAN R V
 
358 33 powerpoint-slides_14-sorting_chapter-14
358 33 powerpoint-slides_14-sorting_chapter-14358 33 powerpoint-slides_14-sorting_chapter-14
358 33 powerpoint-slides_14-sorting_chapter-14
sumitbardhan
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
LegesseSamuel
 
Sorting Algorithms to arrange data in particular format
Sorting Algorithms to arrange data in particular formatSorting Algorithms to arrange data in particular format
Sorting Algorithms to arrange data in particular format
itsusamazahid
 
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptxDSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
suryatom5775
 
Sorting-Algorithms-A-Comprehensive-Guide.pptx
Sorting-Algorithms-A-Comprehensive-Guide.pptxSorting-Algorithms-A-Comprehensive-Guide.pptx
Sorting-Algorithms-A-Comprehensive-Guide.pptx
ReemEmad26
 
Different Searching and Sorting Methods.pptx
Different Searching and Sorting Methods.pptxDifferent Searching and Sorting Methods.pptx
Different Searching and Sorting Methods.pptx
Minakshee Patil
 
Shell sort by group .pptx kkjskanjkkanank
Shell sort by group .pptx kkjskanjkkanankShell sort by group .pptx kkjskanjkkanank
Shell sort by group .pptx kkjskanjkkanank
NIMONAFEKADU
 
Ad

Recently uploaded (20)

Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Ad

Shell Sort and Selection Sort Algorithm

  • 3. It is a highly efficient sorting algorithm and is based on insertion sort algorithm. Shell Sort 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.
  • 4. Uses insertion sort on a widely spread elements, sort them and then sorts the less widely spaced elements. This spacing is termed as interval. Shell Sort This interval is calculated based on Knuth's formula (h = h * 3 +1) where − h is interval with initial value 1
  • 5. This algorithm is quite efficient for medium-sized data sets as its average and worst case complexity are of Ο(n), where n is the number of items. Shell Sort
  • 6. THEOREM:  Any sorting algorithm that only swaps adjacent elements has average time no faster than (O(n^{2})).  The Shell sort (named for its inventor, Donald Shell) is an early and interesting attempt to do this. Shell Sort
  • 7.  Insertion sort is fastest when; a) The array is nearly sorted. b) The array contains only small number of data items Shell Sort  Makes use of intrinsic strength of Insertion sort. THEOREM:
  • 8. Shell Sort  Shell sort works well because : a) It always deals with a small number of elements. b) Elements are moved a long way through array with each swap this leaves it more nearly sorted. THEOREM:
  • 9. Shell Sort Best Case: Shell Sort • The best case in the shell sort is when the array is already sorted in the right order. • The number of comparisons is less.
  • 10. Shell Sort Worst Case: Shell Sort • The running time of Shell sort depends on the choice of increment sequence. • Pairs of increments are not necessarily relatively prime and smaller increments can have little effect.
  • 13. Shell Sort Interval Sequence:  The sequence h1,h2,h3….ht is a sequence of increasing integer values which will be used as a sequence (from right to left) of interval values.
  • 14. • Any sequence will work as long as it is increasing and h1=1. Shell Sort • For any interval value, we all have A[i] <=A[i + h]. • An array A for which this is true is hk sorted. • An array which is hk and is then hk-1 sorted remains as hk sorted.
  • 15.  Implementation of Shell Sort Shell Sort
  • 19. Selection Sort  It sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning.  The algorithm maintains two sub-arrays in a given array. 1) The sub-array which is already sorted. 2) Remaining sub-array which is unsorted.
  • 20. Selection Sort  It is conceptually the simplest sorting algorithm.  It is unstable sort and at the same time it can be also stable.  It is unstable sort and at the same time it can be also stable.
  • 21. Selection Sort  Idea of Selection Sort: Largest-to-Smallest • The first element of the sorted array will be the one with the largest value. • Second will be the largest element of the rest of the array. • Third will be the largest element of the new rest of the array (initial array without the two already sorted elements).
  • 22. Selection Sort HOW DOES SELECTION SORT WORKS? 1ST: Find the index of the largest element and exchange the position with the element at the last index.
  • 23. 2nd: Decrement the last index When the array ends like this, the sorting stops. Selection Sort
  • 24. Selection Sort Three procedures inside the selection sort: 1. Comparison, the times of comparison in a n value array is (n(n-1))/2. 2. Value Assignment, the times of value assignment is between 0 to 3(n-1). 3. Exchanging, the times need is between 0 to (n-1).
  • 25.  Implementation of Selection Sort Selection Sort