SlideShare a Scribd company logo
1 of 18
Shell Sort -General Description

Essentially a segmented insertion sort
Divides an array into several smaller non-contiguous
segments
The distance between successive elements in one
segment is called a gap.
Each segment is sorted within itself using insertion
sort.
Then resegment into larger segments (smaller gaps)
and repeat sort.
Continue until only one segment (gap = 1) - final sort
finishes array sorting.
Shell Sort -Background

General Theory:

Makes use of the intrinsic strengths of Insertion sort. Insertion sort is fastest
when:

The array is nearly sorted.

The array contains only a small number of data items.

Shell sort works well because:

It always deals with a small number of elements.

Elements are moved a long way through array with each swap and this leaves it
more nearly sorted.
Shell Sort - example
80 93 60 6812 8542 30 10
Initial Segmenting Gap = 4 [floor(9/2)] 4
10 30 60 6812 8542 93 80
Shell Sort - example (2)
10 30 60 6812 8542 93 80
Re segmenting Gap [floor(4/2)]= 2
10 12 42 6830 9360 85 80
Shell Sort - example (3)
10 12 30 8042 8560 68 93
10 12 42 6830 9360 85 80
Resegmenting Gap = 1 [floor(2/2)]1
40 2 1 43 3 65 0 -1 58 3 42 4
Original:
5-sort: Sort items with distance 5 element:
40 2 1 43 3 65 0 -1 58 3 42 4
Shell Sort: Idea
Donald Shell (1959): Exchange items that are far apart!
40 2 1 43 3 65 0 -1 58 3 42 4
Original:
40 0 -1 43 3 42 2 1 58 3 65 4
After 5-sort:
2 0 -1 3 1 4 40 3 42 43 65 58
After 3-sort:
Shell Sort: Example
After 1-sort:
1 2 3 40 43 650 421 2 3 3 43 650-1 584 43 6542 5840 43 65
Shell Sort: Gap Values
 Gap: the distance between items being
sorted.
 As we progress, the gap decreases. Shell
Sort is also called Diminishing Gap Sort.
 Shell proposed starting gap of N/2, halving at
each step.
 There are many ways of choosing the next
gap.
Generic Sort
 So far we have methods to sort integers. What about
Strings? Employees? Cookies?
 A new method for each class? No!
 In order to be sorted, objects should be comparable (less
than, equal, greater than).
 Solution:
 use an interface that has a method to compare two objects.
 Remember: A class that implements an interface inherits
the interface (method definitions) = interface inheritance, not
implementation inheritance.
How many squares can you create in this figure by connecting any 4
dots (the corners of a square must lie upon a grid dot?
TRIANGLES:
How many triangles are located in the image below?
There are 11 squares total; 5 small, 4 medium, and 2 large.
27 triangles. There are 16 one-cell triangles, 7 four-cell triangles, 3 nine-cell
triangles, and 1 sixteen-cell triangle.
GUIDED READING
ASSESSMENT
1.Shell sort is a _____ sorting.
a)internal
b)external
c)searching
d)merging
CONTD..
2.The ___________ sort is 5 times faster than the
bubble sort.
a)selection
b)shell
c)insertion
d)merge
CONTD..
3.The _________ sort can also undertake sorting
in
the descending order by selecting the maximum
element.
a)bubble
b)insertion
c)selection
d)shell
CONTD..
4.Diminishing increment sort is a ____________
sort.
a)bubble
b)insertion
c)selection
d)shell
CONTD..
5.The __________ sorting algorithm is only
efficient for medium size lists.
a)insertion
b)bubble
c)shell
d)selection

More Related Content

What's hot

Hash table
Hash tableHash table
Hash tableVu Tran
 
Selection sort 1
Selection sort 1Selection sort 1
Selection sort 1asmhemu
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSAjunnubabu
 
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
 
Selection sort
Selection sortSelection sort
Selection sortamna izzat
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data StructuresSHAKOOR AB
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search treeKrish_ver2
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structuresDurgaDeviCbit
 
Linear search in ds
Linear search in dsLinear search in ds
Linear search in dschauhankapil
 
Insertion sort
Insertion sortInsertion sort
Insertion sortMYER301
 
Radix and Shell sort
Radix and Shell sortRadix and Shell sort
Radix and Shell sorthannatamayao
 
Insertion Sort Algorithm
Insertion Sort AlgorithmInsertion Sort Algorithm
Insertion Sort AlgorithmGail Carmichael
 

What's hot (20)

Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Insertion Sort
Insertion SortInsertion Sort
Insertion Sort
 
Hash table
Hash tableHash table
Hash table
 
Selection sort 1
Selection sort 1Selection sort 1
Selection sort 1
 
Shell sort
Shell sortShell sort
Shell sort
 
Shell sort
Shell sortShell sort
Shell sort
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSA
 
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
 
Selection sort
Selection sortSelection sort
Selection sort
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
Presentation-Merge Sort
Presentation-Merge SortPresentation-Merge Sort
Presentation-Merge Sort
 
Linear search in ds
Linear search in dsLinear search in ds
Linear search in ds
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Insertion sort algorithm power point presentation
Insertion  sort algorithm power point presentation Insertion  sort algorithm power point presentation
Insertion sort algorithm power point presentation
 
Radix and Shell sort
Radix and Shell sortRadix and Shell sort
Radix and Shell sort
 
Insertion Sort Algorithm
Insertion Sort AlgorithmInsertion Sort Algorithm
Insertion Sort Algorithm
 
Hash table
Hash tableHash table
Hash table
 

Viewers also liked

Shellsort
ShellsortShellsort
ShellsortIUPSM
 
ShellSort - Ordenação
ShellSort - OrdenaçãoShellSort - Ordenação
ShellSort - OrdenaçãoAnderson Zardo
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin RamolaDipayan Sarkar
 
Sorting techniques Anil Dutt
Sorting techniques Anil DuttSorting techniques Anil Dutt
Sorting techniques Anil DuttAnil Dutt
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructuresKrish_ver2
 
nhận thiết kế clip quảng cáo giá tốt
nhận thiết kế clip quảng cáo giá tốtnhận thiết kế clip quảng cáo giá tốt
nhận thiết kế clip quảng cáo giá tốtraul110
 
5.4 randamized algorithm
5.4 randamized algorithm5.4 randamized algorithm
5.4 randamized algorithmKrish_ver2
 
CV Belinda Wahl 2015
CV Belinda Wahl 2015CV Belinda Wahl 2015
CV Belinda Wahl 2015Belinda Wahl
 
1.9 b trees eg 03
1.9 b trees eg 031.9 b trees eg 03
1.9 b trees eg 03Krish_ver2
 

Viewers also liked (20)

Shell sort slide
Shell sort slideShell sort slide
Shell sort slide
 
Shell sort
Shell sortShell sort
Shell sort
 
Shell sort
Shell sortShell sort
Shell sort
 
Chapter 8 sorting algo
Chapter 8 sorting algoChapter 8 sorting algo
Chapter 8 sorting algo
 
Shellsort
ShellsortShellsort
Shellsort
 
Radix Sort
Radix SortRadix Sort
Radix Sort
 
Merge sort
Merge sortMerge sort
Merge sort
 
ShellSort - Ordenação
ShellSort - OrdenaçãoShellSort - Ordenação
ShellSort - Ordenação
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin Ramola
 
Sorting techniques Anil Dutt
Sorting techniques Anil DuttSorting techniques Anil Dutt
Sorting techniques Anil Dutt
 
RESUME-ARITRA BHOWMIK
RESUME-ARITRA BHOWMIKRESUME-ARITRA BHOWMIK
RESUME-ARITRA BHOWMIK
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructures
 
4.4 hashing02
4.4 hashing024.4 hashing02
4.4 hashing02
 
4.1 webminig
4.1 webminig 4.1 webminig
4.1 webminig
 
nhận thiết kế clip quảng cáo giá tốt
nhận thiết kế clip quảng cáo giá tốtnhận thiết kế clip quảng cáo giá tốt
nhận thiết kế clip quảng cáo giá tốt
 
5.4 randamized algorithm
5.4 randamized algorithm5.4 randamized algorithm
5.4 randamized algorithm
 
Salario minimo basico
Salario minimo basicoSalario minimo basico
Salario minimo basico
 
CV Belinda Wahl 2015
CV Belinda Wahl 2015CV Belinda Wahl 2015
CV Belinda Wahl 2015
 
1.9 b trees eg 03
1.9 b trees eg 031.9 b trees eg 03
1.9 b trees eg 03
 
Top Forex Brokers
Top Forex BrokersTop Forex Brokers
Top Forex Brokers
 

Similar to 3.3 shell sort

Radix and Merge Sort
Radix and Merge SortRadix and Merge Sort
Radix and Merge SortGelo Maribbay
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.pptLegesseSamuel
 
Sorting Techniques for Data Structures.pptx
Sorting Techniques for Data Structures.pptxSorting Techniques for Data Structures.pptx
Sorting Techniques for Data Structures.pptxKalpana Mohan
 
Sorting Techniques
Sorting TechniquesSorting Techniques
Sorting TechniquesRafay Farooq
 
shell and merge sort
shell and merge sortshell and merge sort
shell and merge sorti i
 
Is sort andy-le
Is sort andy-leIs sort andy-le
Is sort andy-leSumedha
 
Shell Sort and Selection Sort Algorithm
Shell Sort and Selection Sort AlgorithmShell Sort and Selection Sort Algorithm
Shell Sort and Selection Sort AlgorithmRomeo Carinugan
 
Density based Clustering Algorithms(DB SCAN, Mean shift )
Density based Clustering Algorithms(DB SCAN, Mean shift )Density based Clustering Algorithms(DB SCAN, Mean shift )
Density based Clustering Algorithms(DB SCAN, Mean shift )Utkarsh Sharma
 
It elective cs366-barizo-shell
It elective cs366-barizo-shellIt elective cs366-barizo-shell
It elective cs366-barizo-shellChristianBarizo
 
lecture-k-sorting.ppt
lecture-k-sorting.pptlecture-k-sorting.ppt
lecture-k-sorting.pptSushantRaj25
 
Sorting-algorithmbhddcbjkmbgjkuygbjkkius.pdf
Sorting-algorithmbhddcbjkmbgjkuygbjkkius.pdfSorting-algorithmbhddcbjkmbgjkuygbjkkius.pdf
Sorting-algorithmbhddcbjkmbgjkuygbjkkius.pdfArjunSingh81957
 
Chapter 12 - Heaps.ppt
Chapter 12 - Heaps.pptChapter 12 - Heaps.ppt
Chapter 12 - Heaps.pptMouDhara1
 
(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 aiRadhika Srinivasan
 
Lecture 11.2 : sorting
Lecture 11.2 :  sortingLecture 11.2 :  sorting
Lecture 11.2 : sortingVivek Bhargav
 

Similar to 3.3 shell sort (20)

SHELL SORT-2.pptx
SHELL SORT-2.pptxSHELL SORT-2.pptx
SHELL SORT-2.pptx
 
Radix and Merge Sort
Radix and Merge SortRadix and Merge Sort
Radix and Merge Sort
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
 
Sorting Techniques for Data Structures.pptx
Sorting Techniques for Data Structures.pptxSorting Techniques for Data Structures.pptx
Sorting Techniques for Data Structures.pptx
 
sorting_part1.ppt
sorting_part1.pptsorting_part1.ppt
sorting_part1.ppt
 
Sorting Techniques
Sorting TechniquesSorting Techniques
Sorting Techniques
 
shell and merge sort
shell and merge sortshell and merge sort
shell and merge sort
 
Shellshort ppt
Shellshort pptShellshort ppt
Shellshort ppt
 
Is sort andy-le
Is sort andy-leIs sort andy-le
Is sort andy-le
 
Shell Sort and Selection Sort Algorithm
Shell Sort and Selection Sort AlgorithmShell Sort and Selection Sort Algorithm
Shell Sort and Selection Sort Algorithm
 
Density based Clustering Algorithms(DB SCAN, Mean shift )
Density based Clustering Algorithms(DB SCAN, Mean shift )Density based Clustering Algorithms(DB SCAN, Mean shift )
Density based Clustering Algorithms(DB SCAN, Mean shift )
 
It elective cs366-barizo-shell
It elective cs366-barizo-shellIt elective cs366-barizo-shell
It elective cs366-barizo-shell
 
lecture-k-sorting.ppt
lecture-k-sorting.pptlecture-k-sorting.ppt
lecture-k-sorting.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
Lecture k-sorting
Lecture k-sortingLecture k-sorting
Lecture k-sorting
 
Sorting-algorithmbhddcbjkmbgjkuygbjkkius.pdf
Sorting-algorithmbhddcbjkmbgjkuygbjkkius.pdfSorting-algorithmbhddcbjkmbgjkuygbjkkius.pdf
Sorting-algorithmbhddcbjkmbgjkuygbjkkius.pdf
 
Chapter 12 - Heaps.ppt
Chapter 12 - Heaps.pptChapter 12 - Heaps.ppt
Chapter 12 - Heaps.ppt
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai
 
Lecture 11.2 : sorting
Lecture 11.2 :  sortingLecture 11.2 :  sorting
Lecture 11.2 : sorting
 

More from Krish_ver2

5.5 back tracking
5.5 back tracking5.5 back tracking
5.5 back trackingKrish_ver2
 
5.5 back track
5.5 back track5.5 back track
5.5 back trackKrish_ver2
 
5.5 back tracking 02
5.5 back tracking 025.5 back tracking 02
5.5 back tracking 02Krish_ver2
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructuresKrish_ver2
 
5.3 dynamic programming 03
5.3 dynamic programming 035.3 dynamic programming 03
5.3 dynamic programming 03Krish_ver2
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programmingKrish_ver2
 
5.3 dyn algo-i
5.3 dyn algo-i5.3 dyn algo-i
5.3 dyn algo-iKrish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03Krish_ver2
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquerKrish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03Krish_ver2
 
5.1 greedyyy 02
5.1 greedyyy 025.1 greedyyy 02
5.1 greedyyy 02Krish_ver2
 
4.4 hashing ext
4.4 hashing  ext4.4 hashing  ext
4.4 hashing extKrish_ver2
 
4.4 external hashing
4.4 external hashing4.4 external hashing
4.4 external hashingKrish_ver2
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal searchKrish_ver2
 

More from Krish_ver2 (20)

5.5 back tracking
5.5 back tracking5.5 back tracking
5.5 back tracking
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
 
5.5 back tracking 02
5.5 back tracking 025.5 back tracking 02
5.5 back tracking 02
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructures
 
5.3 dynamic programming 03
5.3 dynamic programming 035.3 dynamic programming 03
5.3 dynamic programming 03
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programming
 
5.3 dyn algo-i
5.3 dyn algo-i5.3 dyn algo-i
5.3 dyn algo-i
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquer
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
 
5.1 greedyyy 02
5.1 greedyyy 025.1 greedyyy 02
5.1 greedyyy 02
 
5.1 greedy
5.1 greedy5.1 greedy
5.1 greedy
 
5.1 greedy 03
5.1 greedy 035.1 greedy 03
5.1 greedy 03
 
4.4 hashing
4.4 hashing4.4 hashing
4.4 hashing
 
4.4 hashing ext
4.4 hashing  ext4.4 hashing  ext
4.4 hashing ext
 
4.4 external hashing
4.4 external hashing4.4 external hashing
4.4 external hashing
 
4.2 bst
4.2 bst4.2 bst
4.2 bst
 
4.2 bst 03
4.2 bst 034.2 bst 03
4.2 bst 03
 
4.2 bst 02
4.2 bst 024.2 bst 02
4.2 bst 02
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal search
 

Recently uploaded

THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 

Recently uploaded (20)

THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 

3.3 shell sort

  • 1. Shell Sort -General Description  Essentially a segmented insertion sort Divides an array into several smaller non-contiguous segments The distance between successive elements in one segment is called a gap. Each segment is sorted within itself using insertion sort. Then resegment into larger segments (smaller gaps) and repeat sort. Continue until only one segment (gap = 1) - final sort finishes array sorting.
  • 2. Shell Sort -Background  General Theory:  Makes use of the intrinsic strengths of Insertion sort. Insertion sort is fastest when:  The array is nearly sorted.  The array contains only a small number of data items.  Shell sort works well because:  It always deals with a small number of elements.  Elements are moved a long way through array with each swap and this leaves it more nearly sorted.
  • 3. Shell Sort - example 80 93 60 6812 8542 30 10 Initial Segmenting Gap = 4 [floor(9/2)] 4 10 30 60 6812 8542 93 80
  • 4. Shell Sort - example (2) 10 30 60 6812 8542 93 80 Re segmenting Gap [floor(4/2)]= 2 10 12 42 6830 9360 85 80
  • 5. Shell Sort - example (3) 10 12 30 8042 8560 68 93 10 12 42 6830 9360 85 80 Resegmenting Gap = 1 [floor(2/2)]1
  • 6. 40 2 1 43 3 65 0 -1 58 3 42 4 Original: 5-sort: Sort items with distance 5 element: 40 2 1 43 3 65 0 -1 58 3 42 4 Shell Sort: Idea Donald Shell (1959): Exchange items that are far apart!
  • 7. 40 2 1 43 3 65 0 -1 58 3 42 4 Original: 40 0 -1 43 3 42 2 1 58 3 65 4 After 5-sort: 2 0 -1 3 1 4 40 3 42 43 65 58 After 3-sort: Shell Sort: Example After 1-sort: 1 2 3 40 43 650 421 2 3 3 43 650-1 584 43 6542 5840 43 65
  • 8. Shell Sort: Gap Values  Gap: the distance between items being sorted.  As we progress, the gap decreases. Shell Sort is also called Diminishing Gap Sort.  Shell proposed starting gap of N/2, halving at each step.  There are many ways of choosing the next gap.
  • 9. Generic Sort  So far we have methods to sort integers. What about Strings? Employees? Cookies?  A new method for each class? No!  In order to be sorted, objects should be comparable (less than, equal, greater than).  Solution:  use an interface that has a method to compare two objects.  Remember: A class that implements an interface inherits the interface (method definitions) = interface inheritance, not implementation inheritance.
  • 10. How many squares can you create in this figure by connecting any 4 dots (the corners of a square must lie upon a grid dot? TRIANGLES: How many triangles are located in the image below?
  • 11. There are 11 squares total; 5 small, 4 medium, and 2 large. 27 triangles. There are 16 one-cell triangles, 7 four-cell triangles, 3 nine-cell triangles, and 1 sixteen-cell triangle.
  • 13.
  • 14. ASSESSMENT 1.Shell sort is a _____ sorting. a)internal b)external c)searching d)merging
  • 15. CONTD.. 2.The ___________ sort is 5 times faster than the bubble sort. a)selection b)shell c)insertion d)merge
  • 16. CONTD.. 3.The _________ sort can also undertake sorting in the descending order by selecting the maximum element. a)bubble b)insertion c)selection d)shell
  • 17. CONTD.. 4.Diminishing increment sort is a ____________ sort. a)bubble b)insertion c)selection d)shell
  • 18. CONTD.. 5.The __________ sorting algorithm is only efficient for medium size lists. a)insertion b)bubble c)shell d)selection