SlideShare una empresa de Scribd logo
1 de 52
S O R T I N G A lecture by   ABDUL GHAFFAR  Chapter 3  Of  Reference  #1
Reference Books ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Contents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],link2
Selection Sort  ( Ref # 2- 9.4) ,[object Object],[object Object],[object Object]
Selection Sort  (continue..)
Insertion Sort  (Ref #1-7.2,  Ref  2- 9.3)
Insertion Sort  (continue..)
Insertion Sort  (continue..)
Insertion Sort  (continue..)
Merge Sort  (Ref # 1- 7.6, Ref #2-8,9.6) ,[object Object]
Merge Sort  (continue..) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Merge Sort  (continue..)
Merge Sort  (continue..) Implementation in C++
Merge Sort  (continue..) Implementation in C++ Merging The Merge function of the TwoWayMergeSorter<T> class is defined in Program    . Altogether, this function takes four parameters: The first is a reference to the array to be sorted. The remaining three, left, middle, and right, are unsigned integers. It is assumed that  Furthermore, it is assumed that the two subsequences of the array,  and  are both sorted. The Merge routine merges the two sorted subsequences using the temporary array specified by tempArray. It then copies the merged (and sorted) sequence into the array at
Merge Sort  (continue..) Implementation in C++
Merge Sort  (continue..) Implementation in C++
Quick Sort ( Ref #1-7.x, Ref#2-x,y) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Quick Sort  ( Continue… ) ,[object Object],[object Object],[object Object]
Quick Sort  ( Continue… ) ,[object Object],[object Object],Example
Quick Sort  ( Continue… ) Example
Quick Sort  ( Continue… ) Example
Quick Sort  ( Continue… ) ,[object Object],[object Object],[object Object],[object Object],Implementation in C
Quick Sort  ( Continue… ) Implementation in C
Heap Sort ( Ref #1-7.7,  Ref #2 -9.10) ,[object Object],[object Object],[object Object]
Heap Sort  (Continue..) ,[object Object],[object Object]
Heap Sort  (Continue..) Array representation of Binary Tree
Heap Sort  (Continue..) ,[object Object],[object Object]
Heap Sort  (Continue..) ,[object Object],[object Object],[object Object],[object Object]
Heap Sort  (Continue..) ,[object Object]
Heap Sort  (Continue..) ,[object Object]
Heap Sort  (Continue..) ,[object Object],[object Object],[object Object],[object Object]
Heap Sort  (Continue..)  Building a heap
Heap Sort  (Continue..)  Building a heap
Heap Sort  (Continue..)  Building a heap The Algorithm
Heap Sort  (Continue..) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Heap Sort  (Continue..) Deleting the Root, an Example
Heap Sort  (Continue..)    Deleting the root (Algorithm)
Heap Sort  (Continue..)    Application algorithm
Heap Sort  (Continue..)  Implementation in C++
Heap Sort  (Continue..)  Implementation in C++
Heap Sort  (Continue..)  Implementation in C++
Heap Sort  (Continue..)  Implementation in C++
Heap Sort  (Continue..)  Implementation in C++
Heap Sort  (Continue..)  Implementation in C++ The Sorting Phase : Once the max heap has been built, heapsort proceeds to the sorting phase.b The sorting phase of heapsort works like this: We repeatedly swap the largest element in the heap (always in position 1) into the next position of the sorted sequence. After each such swap, there is a new value at the root of the heap and this new value is pushed down into the correct  position in the heap using the Percolate  Down routine.
Heap Sort  (Continue..)  Implementation in C++ The Sorting Phase : The next example explains this phase
Heap Sort  (Continue..)  Example
Heap Sort  (Continue..)  Example
Heap Sort  (Continue..)  Example
Heap Sort  (Continue..)  Example
External Sort
External Sort  (continue…)
External Sort  (continue…)

Más contenido relacionado

La actualidad más candente (20)

Insertion sort
Insertion sortInsertion sort
Insertion sort
 
single linked list
single linked listsingle linked list
single linked list
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queue
 
Quick sort
Quick sortQuick sort
Quick sort
 
Quick sort
Quick sortQuick sort
Quick 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
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2
 
Linked lists
Linked listsLinked lists
Linked lists
 
Sorting
SortingSorting
Sorting
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
 
Singly & Circular Linked list
Singly & Circular Linked listSingly & Circular Linked list
Singly & Circular Linked list
 
Expression trees
Expression treesExpression trees
Expression trees
 
Deletion from single way linked list and search
Deletion from single way linked list and searchDeletion from single way linked list and search
Deletion from single way linked list and search
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
 
Merge Sort
Merge SortMerge Sort
Merge Sort
 

Similar a Sorting

Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.pptLegesseSamuel
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3infanciaj
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arraysmaamir farooq
 
VCE Unit 04vv.pptx
VCE Unit 04vv.pptxVCE Unit 04vv.pptx
VCE Unit 04vv.pptxskilljiolms
 
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...Tosin Amuda
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptxskilljiolms
 
Selection sort
Selection sortSelection sort
Selection sortasra khan
 
lecture-k-sorting.ppt
lecture-k-sorting.pptlecture-k-sorting.ppt
lecture-k-sorting.pptSushantRaj25
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sortingsajinis3
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0BG Java EE Course
 
Address calculation-sort
Address calculation-sortAddress calculation-sort
Address calculation-sortVasim Pathan
 
Insersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmInsersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmEhsan Ehrari
 

Similar a Sorting (20)

Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
 
Heap, quick and merge sort
Heap, quick and merge sortHeap, quick and merge sort
Heap, quick and merge sort
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arrays
 
VCE Unit 04vv.pptx
VCE Unit 04vv.pptxVCE Unit 04vv.pptx
VCE Unit 04vv.pptx
 
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
Sorting2
Sorting2Sorting2
Sorting2
 
Sorting
SortingSorting
Sorting
 
Selection sort
Selection sortSelection sort
Selection sort
 
Sorting
SortingSorting
Sorting
 
Unit6 C
Unit6 C Unit6 C
Unit6 C
 
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
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
Address calculation-sort
Address calculation-sortAddress calculation-sort
Address calculation-sort
 
Chapter3.pptx
Chapter3.pptxChapter3.pptx
Chapter3.pptx
 
Insersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmInsersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in Algoritm
 

Más de Ghaffar Khan

World is beautiful ... ...
World is beautiful ... ...World is beautiful ... ...
World is beautiful ... ...Ghaffar Khan
 
My Presentation On Ajax
My Presentation On AjaxMy Presentation On Ajax
My Presentation On AjaxGhaffar Khan
 
How A Computer Works
How A Computer WorksHow A Computer Works
How A Computer WorksGhaffar Khan
 
Exponential and Logarthmic funtions
Exponential and Logarthmic funtionsExponential and Logarthmic funtions
Exponential and Logarthmic funtionsGhaffar Khan
 
Exponential and Logarthmic funtions (1)
Exponential and Logarthmic funtions (1)Exponential and Logarthmic funtions (1)
Exponential and Logarthmic funtions (1)Ghaffar Khan
 
Quadratic And Polinomial Function
Quadratic And Polinomial FunctionQuadratic And Polinomial Function
Quadratic And Polinomial FunctionGhaffar Khan
 
Quadratic And Polinomial Function
 Quadratic And Polinomial Function Quadratic And Polinomial Function
Quadratic And Polinomial FunctionGhaffar Khan
 
Exponentioal And Logarthmic Functions
 Exponentioal And Logarthmic Functions Exponentioal And Logarthmic Functions
Exponentioal And Logarthmic FunctionsGhaffar Khan
 
Introduction to Computer Networks
 Introduction to Computer Networks Introduction to Computer Networks
Introduction to Computer NetworksGhaffar Khan
 
Control Structures
Control StructuresControl Structures
Control StructuresGhaffar Khan
 
Computer Graphics Introduction
Computer Graphics IntroductionComputer Graphics Introduction
Computer Graphics IntroductionGhaffar Khan
 

Más de Ghaffar Khan (20)

World is beautiful ... ...
World is beautiful ... ...World is beautiful ... ...
World is beautiful ... ...
 
My Presentation On Ajax
My Presentation On AjaxMy Presentation On Ajax
My Presentation On Ajax
 
How A Computer Works
How A Computer WorksHow A Computer Works
How A Computer Works
 
For Loop
For LoopFor Loop
For Loop
 
Exponential and Logarthmic funtions
Exponential and Logarthmic funtionsExponential and Logarthmic funtions
Exponential and Logarthmic funtions
 
Exponential and Logarthmic funtions (1)
Exponential and Logarthmic funtions (1)Exponential and Logarthmic funtions (1)
Exponential and Logarthmic funtions (1)
 
Functions
FunctionsFunctions
Functions
 
Quadratic And Polinomial Function
Quadratic And Polinomial FunctionQuadratic And Polinomial Function
Quadratic And Polinomial Function
 
Quadratic And Polinomial Function
 Quadratic And Polinomial Function Quadratic And Polinomial Function
Quadratic And Polinomial Function
 
Exponentioal And Logarthmic Functions
 Exponentioal And Logarthmic Functions Exponentioal And Logarthmic Functions
Exponentioal And Logarthmic Functions
 
Internet Protocol
Internet ProtocolInternet Protocol
Internet Protocol
 
Introduction to Computer Networks
 Introduction to Computer Networks Introduction to Computer Networks
Introduction to Computer Networks
 
Network Layer
Network LayerNetwork Layer
Network Layer
 
Control Structures
Control StructuresControl Structures
Control Structures
 
Input And Output
 Input And Output Input And Output
Input And Output
 
Surfaces
SurfacesSurfaces
Surfaces
 
Vector Tools
Vector ToolsVector Tools
Vector Tools
 
Drawing Tools
Drawing ToolsDrawing Tools
Drawing Tools
 
Drawing Figures
Drawing FiguresDrawing Figures
Drawing Figures
 
Computer Graphics Introduction
Computer Graphics IntroductionComputer Graphics Introduction
Computer Graphics Introduction
 

Último

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Sorting

  • 1. S O R T I N G A lecture by ABDUL GHAFFAR Chapter 3 Of Reference #1
  • 2.
  • 3.
  • 4.
  • 5. Selection Sort (continue..)
  • 6. Insertion Sort (Ref #1-7.2, Ref 2- 9.3)
  • 7. Insertion Sort (continue..)
  • 8. Insertion Sort (continue..)
  • 9. Insertion Sort (continue..)
  • 10.
  • 11.
  • 12. Merge Sort (continue..)
  • 13. Merge Sort (continue..) Implementation in C++
  • 14. Merge Sort (continue..) Implementation in C++ Merging The Merge function of the TwoWayMergeSorter<T> class is defined in Program  . Altogether, this function takes four parameters: The first is a reference to the array to be sorted. The remaining three, left, middle, and right, are unsigned integers. It is assumed that Furthermore, it is assumed that the two subsequences of the array, and are both sorted. The Merge routine merges the two sorted subsequences using the temporary array specified by tempArray. It then copies the merged (and sorted) sequence into the array at
  • 15. Merge Sort (continue..) Implementation in C++
  • 16. Merge Sort (continue..) Implementation in C++
  • 17.
  • 18.
  • 19.
  • 20. Quick Sort ( Continue… ) Example
  • 21. Quick Sort ( Continue… ) Example
  • 22.
  • 23. Quick Sort ( Continue… ) Implementation in C
  • 24.
  • 25.
  • 26. Heap Sort (Continue..) Array representation of Binary Tree
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. Heap Sort (Continue..) Building a heap
  • 33. Heap Sort (Continue..) Building a heap
  • 34. Heap Sort (Continue..) Building a heap The Algorithm
  • 35.
  • 36. Heap Sort (Continue..) Deleting the Root, an Example
  • 37. Heap Sort (Continue..) Deleting the root (Algorithm)
  • 38. Heap Sort (Continue..) Application algorithm
  • 39. Heap Sort (Continue..) Implementation in C++
  • 40. Heap Sort (Continue..) Implementation in C++
  • 41. Heap Sort (Continue..) Implementation in C++
  • 42. Heap Sort (Continue..) Implementation in C++
  • 43. Heap Sort (Continue..) Implementation in C++
  • 44. Heap Sort (Continue..) Implementation in C++ The Sorting Phase : Once the max heap has been built, heapsort proceeds to the sorting phase.b The sorting phase of heapsort works like this: We repeatedly swap the largest element in the heap (always in position 1) into the next position of the sorted sequence. After each such swap, there is a new value at the root of the heap and this new value is pushed down into the correct position in the heap using the Percolate Down routine.
  • 45. Heap Sort (Continue..) Implementation in C++ The Sorting Phase : The next example explains this phase
  • 46. Heap Sort (Continue..) Example
  • 47. Heap Sort (Continue..) Example
  • 48. Heap Sort (Continue..) Example
  • 49. Heap Sort (Continue..) Example
  • 51. External Sort (continue…)
  • 52. External Sort (continue…)