SlideShare une entreprise Scribd logo
1  sur  12
SORTING
By:-
Kumar siddharth bansal- 100101114
Mansi mahajan -100101126
Anadi vats- 100101030
Jishnu v. nair- 100101100
Anele kingsley .c- 100101033
Emiri Charles Ugo- 100101085
Johnson Barimlenea Dandy- 100101102
WHAT IS SORTING???
 Sorting is the process of
putting a list or a group of
items in a specific order.
Some common sorting criteria
are: alphabetical or numerical.
SHELL SORT
•      Use increment sequence h 1, h2, …ht. After phase using increment hk, a[i] <= a[i+ hk]


for each hk
    for i = hk to a.size()
     tmp = a[i]
     for j = i j >= hk && tmp < a[j- hk] j-= hk
      a[j] = a[j- hk ]
     a[j] = tmp
BUBBLE SORT
•   This algorithm sorts the array A with the N elements.
    1. Initialise Set I=0
    2. Repeat steps 3 to 5 until I<N
•   3. Set J=0
•   4. Repeat step 5 until J<N-i-1
•   5. If A[J]> A[J+1] then
•      Set temp= A[J]
•      Set A[J]=A[J+1]
•      Set A[J+1]= temp
•   END IF
•   6. exit
QUICK SORT
•   Quicksort (a,l,h)
•   Where
•   a: represents the list of elements.
•   l: represents the position of the first element in the        list (only at the starting point , it’s value changes during the
    execution of the function) .
•   h: represents the position of the last element in the list.
•   1: (Initially)
•       low=l
•       high=h
        key=a[(1+h)/2] { for middle element of the list}
•   2: Repeat through step 7 while (low <=high)
•   3: Repeat 4 while (a([low]<key)
•   4: low=low+1
•   5: Repeat 6 while (a([high]<key))
•   6: high=high-1
•   7: if(low<=high)
•     (a) temp=a[low]
•     (b) a[low]=a[high]
•     (c) a[high]=temp
•     (d) low=low+1
•     (e) high=high-1
•   8: if(l<high) Quick_sort(a,l,high)
•   9: if(low<h) Quick_sort(a,low,h)
•   10: Exit
SELECTION SORT
•   1. Repeat steps 2 & 3 for k=1,2,…,n-1:
•   2. Call min(a,k,n,loc).
•   3. [Interchange a[k] and a[loc].]
•
•   Set temp: = a[k]
•   a[k]= a[loc]
•   a[loc]= temp
•
    [END OF STEP 1]
•   4. Exit
RADIX SORT
1. Find the largest element of the array.
2. Find the total number of digits num in the largets digit.
  set digit =num
3. Repeat steps 4,5 for pass=1 to num
4.Initialise buckets
  for i=1 to (n-1)
Set num=obtain digit number pass of a[i]
Put a[i] in bucket number digit
[END OF FOR LOOP]
5. Calculate all numbers from the bucket in order.
6. Exit.
MERGE SORT
•   If the list is of length 0 or 1, then it is already sorted. Otherwise:
•   Divide the unsorted list into two sublists of about half the size.
•   Sort each sublist recursively by re-applying the merge sort.
•   Mergr the two sublists back into one sorted list.
•   Merge sort incorporates two main ideas to improve its runtime:
•   A small list will take fewer steps to sort than a large list.
•   Fewer steps are required to construct a sorted list from two sorted lists than from two
    unsorted lists. For example, you only have to traverse each list once if they're already
    sorted.
HEAP SORT
• The heap data structure is an array object which can
  be easily visualized as a complete binary tree. There is
  a one to one correspondence between elements of the
  array and nodes of the tree. The tree is completely
  filled on all levels except possibly the lowest, which is
  filled from the left upto a point. All nodes of heap also
  satisfy the relation that the key values at each node is
  at least as large as the value at its children
ALGORITHM
•   The user inputs the size of the heap (within the specified limit). The program
    generates a corresponding binary tree with the nodes having randomly
    generated key values
•   Build heap operation: Let n be the number of nodes in the tree and I be the key
    of a tree. For this, the program uses operation heapify, when Heapify is called
    both the left and right subtree of the I are heaps. The function of heapify is to let
    I settle down to a position (by swapping itself with the larger of its
    children, whenever the heap property is not satisfied) till the heap property is
    satisfied in the tree which was rooted at i.
•   Remove maximum element: The program removes the largest element of the
    heap (the root) by swapping it with the last element.
•   The program executes Heapify (new root) so that the resultig tree satisfies the
    heap property
•   Goto step iii till heap is empty
Sorting

Contenu connexe

Tendances (20)

Heap sort
Heap sortHeap sort
Heap sort
 
Heaps
HeapsHeaps
Heaps
 
Heap Sort in Design and Analysis of algorithms
Heap Sort in Design and Analysis of algorithmsHeap Sort in Design and Analysis of algorithms
Heap Sort in Design and Analysis of algorithms
 
Heap sort
Heap sort Heap sort
Heap sort
 
Array linear data_structure_2 (1)
Array linear data_structure_2 (1)Array linear data_structure_2 (1)
Array linear data_structure_2 (1)
 
Heap, quick and merge sort
Heap, quick and merge sortHeap, quick and merge sort
Heap, quick and merge sort
 
Heaps
HeapsHeaps
Heaps
 
Nikit
NikitNikit
Nikit
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing concepts
 
Heaps
HeapsHeaps
Heaps
 
arrays
arraysarrays
arrays
 
Linked list
Linked listLinked list
Linked list
 
Python List Comprehensions
Python List ComprehensionsPython List Comprehensions
Python List Comprehensions
 
Heap and heapsort
Heap and heapsortHeap and heapsort
Heap and heapsort
 
Heap sort
Heap sortHeap sort
Heap sort
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
 
Unit 7 sorting
Unit   7 sortingUnit   7 sorting
Unit 7 sorting
 
Heap sort
Heap sortHeap sort
Heap sort
 
Array 2
Array 2Array 2
Array 2
 
Heap sort
Heap sortHeap sort
Heap sort
 

En vedette

Bubble sort
Bubble sort Bubble sort
Bubble sort rmsz786
 
Selection sort
Selection sortSelection sort
Selection sortstella D
 
3.4 selection sort
3.4 selection sort3.4 selection sort
3.4 selection sortKrish_ver2
 
Selection sort
Selection sortSelection sort
Selection sortasra khan
 
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topicSaddam Hussain
 
Selection sort
Selection sortSelection sort
Selection sortJay Patel
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...widespreadpromotion
 
3.1 bubble sort
3.1 bubble sort3.1 bubble sort
3.1 bubble sortKrish_ver2
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary SearchReem Alattas
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithmNeoClassical
 
Linear Search Data Structure
Linear Search Data StructureLinear Search Data Structure
Linear Search Data StructureTalha Shaikh
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithmsmultimedia9
 
Bubble Sort
Bubble SortBubble Sort
Bubble Sortgeeortiz
 

En vedette (20)

sort search in C
 sort search in C  sort search in C
sort search in C
 
Linear and Bianry search
Linear and Bianry searchLinear and Bianry search
Linear and Bianry search
 
Bubble sort
Bubble sort Bubble sort
Bubble sort
 
Selection sort
Selection sortSelection sort
Selection sort
 
The selection sort algorithm
The selection sort algorithmThe selection sort algorithm
The selection sort algorithm
 
Bubble sort algorithm
Bubble sort algorithmBubble sort algorithm
Bubble sort algorithm
 
3.4 selection sort
3.4 selection sort3.4 selection sort
3.4 selection sort
 
Selection sort
Selection sortSelection sort
Selection sort
 
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topic
 
Selection sort
Selection sortSelection sort
Selection sort
 
Selection sort
Selection sortSelection sort
Selection sort
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
 
3.1 bubble sort
3.1 bubble sort3.1 bubble sort
3.1 bubble sort
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary Search
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithm
 
Linear Search Data Structure
Linear Search Data StructureLinear Search Data Structure
Linear Search Data Structure
 
Sorting
SortingSorting
Sorting
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Bubble Sort
Bubble SortBubble Sort
Bubble Sort
 

Similaire à Sorting

Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing conceptsLJ Projects
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3infanciaj
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sortingFadhil Ismail
 
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 analysisRadhika Talaviya
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingEduardo Bergavera
 
An Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List AlgorithmsAn Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List AlgorithmsBlue Elephant Consulting
 
DS Unit 1.pptx
DS Unit 1.pptxDS Unit 1.pptx
DS Unit 1.pptxchin463670
 
Data analysis and algorithms - UNIT 2.pptx
Data analysis and algorithms - UNIT 2.pptxData analysis and algorithms - UNIT 2.pptx
Data analysis and algorithms - UNIT 2.pptxsgrishma559
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.pptLegesseSamuel
 
21. Heap_new.ppt
21. Heap_new.ppt21. Heap_new.ppt
21. Heap_new.pptAryanGour1
 
VCE Unit 04vv.pptx
VCE Unit 04vv.pptxVCE Unit 04vv.pptx
VCE Unit 04vv.pptxskilljiolms
 
Unit III Version I.pptx
Unit III Version I.pptxUnit III Version I.pptx
Unit III Version I.pptxssuserd602fd
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sortKrish_ver2
 
Searching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structuresSearching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structuresPRIANKA R
 

Similaire à Sorting (20)

Unit vii sorting
Unit   vii sorting Unit   vii sorting
Unit vii sorting
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing concepts
 
Algorithms - "heap sort"
Algorithms - "heap sort"Algorithms - "heap sort"
Algorithms - "heap sort"
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
 
Unit viii searching and hashing
Unit   viii searching and hashing Unit   viii searching and hashing
Unit viii searching and hashing
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting
 
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
 
Unit 8 searching and hashing
Unit   8 searching and hashingUnit   8 searching and hashing
Unit 8 searching and hashing
 
Lecture_Oct26.pptx
Lecture_Oct26.pptxLecture_Oct26.pptx
Lecture_Oct26.pptx
 
sorting-160810203705.pptx
sorting-160810203705.pptxsorting-160810203705.pptx
sorting-160810203705.pptx
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
 
An Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List AlgorithmsAn Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List Algorithms
 
DS Unit 1.pptx
DS Unit 1.pptxDS Unit 1.pptx
DS Unit 1.pptx
 
Data analysis and algorithms - UNIT 2.pptx
Data analysis and algorithms - UNIT 2.pptxData analysis and algorithms - UNIT 2.pptx
Data analysis and algorithms - UNIT 2.pptx
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
 
21. Heap_new.ppt
21. Heap_new.ppt21. Heap_new.ppt
21. Heap_new.ppt
 
VCE Unit 04vv.pptx
VCE Unit 04vv.pptxVCE Unit 04vv.pptx
VCE Unit 04vv.pptx
 
Unit III Version I.pptx
Unit III Version I.pptxUnit III Version I.pptx
Unit III Version I.pptx
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sort
 
Searching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structuresSearching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structures
 

Plus de vatsaanadi

Plus de vatsaanadi (7)

Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Social networking
Social networkingSocial networking
Social networking
 
Ds
DsDs
Ds
 
Save the change
Save the changeSave the change
Save the change
 
Windows vs linux
Windows vs linuxWindows vs linux
Windows vs linux
 
Sampling
SamplingSampling
Sampling
 
Dbms
DbmsDbms
Dbms
 

Dernier

Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
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.pdfAdmir Softic
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
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.pptxMaritesTamaniVerdade
 
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 17Celine George
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
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Ữ Â...Nguyen Thanh Tu Collection
 

Dernier (20)

Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
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
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
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
 
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
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
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Ữ Â...
 

Sorting

  • 1. SORTING By:- Kumar siddharth bansal- 100101114 Mansi mahajan -100101126 Anadi vats- 100101030 Jishnu v. nair- 100101100 Anele kingsley .c- 100101033 Emiri Charles Ugo- 100101085 Johnson Barimlenea Dandy- 100101102
  • 2. WHAT IS SORTING??? Sorting is the process of putting a list or a group of items in a specific order. Some common sorting criteria are: alphabetical or numerical.
  • 3. SHELL SORT • Use increment sequence h 1, h2, …ht. After phase using increment hk, a[i] <= a[i+ hk] for each hk for i = hk to a.size() tmp = a[i] for j = i j >= hk && tmp < a[j- hk] j-= hk a[j] = a[j- hk ] a[j] = tmp
  • 4. BUBBLE SORT • This algorithm sorts the array A with the N elements. 1. Initialise Set I=0 2. Repeat steps 3 to 5 until I<N • 3. Set J=0 • 4. Repeat step 5 until J<N-i-1 • 5. If A[J]> A[J+1] then • Set temp= A[J] • Set A[J]=A[J+1] • Set A[J+1]= temp • END IF • 6. exit
  • 5. QUICK SORT • Quicksort (a,l,h) • Where • a: represents the list of elements. • l: represents the position of the first element in the list (only at the starting point , it’s value changes during the execution of the function) . • h: represents the position of the last element in the list. • 1: (Initially) • low=l • high=h key=a[(1+h)/2] { for middle element of the list} • 2: Repeat through step 7 while (low <=high) • 3: Repeat 4 while (a([low]<key) • 4: low=low+1 • 5: Repeat 6 while (a([high]<key)) • 6: high=high-1
  • 6. 7: if(low<=high) • (a) temp=a[low] • (b) a[low]=a[high] • (c) a[high]=temp • (d) low=low+1 • (e) high=high-1 • 8: if(l<high) Quick_sort(a,l,high) • 9: if(low<h) Quick_sort(a,low,h) • 10: Exit
  • 7. SELECTION SORT • 1. Repeat steps 2 & 3 for k=1,2,…,n-1: • 2. Call min(a,k,n,loc). • 3. [Interchange a[k] and a[loc].] • • Set temp: = a[k] • a[k]= a[loc] • a[loc]= temp • [END OF STEP 1] • 4. Exit
  • 8. RADIX SORT 1. Find the largest element of the array. 2. Find the total number of digits num in the largets digit. set digit =num 3. Repeat steps 4,5 for pass=1 to num 4.Initialise buckets for i=1 to (n-1) Set num=obtain digit number pass of a[i] Put a[i] in bucket number digit [END OF FOR LOOP] 5. Calculate all numbers from the bucket in order. 6. Exit.
  • 9. MERGE SORT • If the list is of length 0 or 1, then it is already sorted. Otherwise: • Divide the unsorted list into two sublists of about half the size. • Sort each sublist recursively by re-applying the merge sort. • Mergr the two sublists back into one sorted list. • Merge sort incorporates two main ideas to improve its runtime: • A small list will take fewer steps to sort than a large list. • Fewer steps are required to construct a sorted list from two sorted lists than from two unsorted lists. For example, you only have to traverse each list once if they're already sorted.
  • 10. HEAP SORT • The heap data structure is an array object which can be easily visualized as a complete binary tree. There is a one to one correspondence between elements of the array and nodes of the tree. The tree is completely filled on all levels except possibly the lowest, which is filled from the left upto a point. All nodes of heap also satisfy the relation that the key values at each node is at least as large as the value at its children
  • 11. ALGORITHM • The user inputs the size of the heap (within the specified limit). The program generates a corresponding binary tree with the nodes having randomly generated key values • Build heap operation: Let n be the number of nodes in the tree and I be the key of a tree. For this, the program uses operation heapify, when Heapify is called both the left and right subtree of the I are heaps. The function of heapify is to let I settle down to a position (by swapping itself with the larger of its children, whenever the heap property is not satisfied) till the heap property is satisfied in the tree which was rooted at i. • Remove maximum element: The program removes the largest element of the heap (the root) by swapping it with the last element. • The program executes Heapify (new root) so that the resultig tree satisfies the heap property • Goto step iii till heap is empty