SlideShare a Scribd company logo
1 of 14
Algorithms Task-4
By/ Saad Mohamed Saad
Merge Sort Pseudocode
Quick Sort Problem
5 3 1 9 8 2 4 7
left right
pivot
Sorting list of Numbers
[5, 3, 1, 9, 8, 2, 4, 7]
5 3 1 9 8 2 4 7
left right
pivot
Comparing left with right and sort
small numbers at the left
Here, the left and right
are already sorted
5 3 1 9 8 2 4 7
left right
pivot
Algorithm moves forward one
position towards left
5 3 1 9 8 2 4 7
left right
pivot
Doing the same thing to compare left with
right and sort small numbers at the left
Here, the left and
right are not sorted
4 3 1 9 8 2 5 7
right
left
pivot
So, we swap value in the left
with its in the right
And the pivot stays
points at the same value
4 3 1 9 8 2 5 7
right
left
pivot
And then left will move to
the next index
4 3 1 9 8 2 5 7
right
left
pivot
Then, we repeat the same steps with each
element to get left, right and pivot at the
same index. Hence, the element is sorted
4 3 1 2 5 8 9 7
right
left
pivot
Here, (5) is sorted. And we surely know that
elements on its left is smaller than its right
1 2 3 4 5 7 8 9
right
left
pivot
We do the same thing recursively to the two
left and right sub array of the pivot element
until we get the list sorted as seen;
Thank You
Any Question.?

More Related Content

Similar to Algorithms Task-4.pdf (10)

sorting and searching.pptx
sorting and searching.pptxsorting and searching.pptx
sorting and searching.pptx
 
Insertion Sort, Quick Sort And Their complexity
Insertion Sort, Quick Sort And Their complexityInsertion Sort, Quick Sort And Their complexity
Insertion Sort, Quick Sort And Their complexity
 
Absolute Value and the Fundamental Operations on Integers.pptx
Absolute Value and the Fundamental Operations on Integers.pptxAbsolute Value and the Fundamental Operations on Integers.pptx
Absolute Value and the Fundamental Operations on Integers.pptx
 
Algorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary SearchAlgorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary Search
 
Introduction to Positive and Negative Numbers
Introduction to Positive and Negative NumbersIntroduction to Positive and Negative Numbers
Introduction to Positive and Negative Numbers
 
Add and subtract pos and neg numbers 4 parts
Add and subtract pos and neg numbers 4 partsAdd and subtract pos and neg numbers 4 parts
Add and subtract pos and neg numbers 4 parts
 
Chapter 1 Study Guide
Chapter 1  Study  GuideChapter 1  Study  Guide
Chapter 1 Study Guide
 
Chapter 1 Study Guide
Chapter 1  Study  GuideChapter 1  Study  Guide
Chapter 1 Study Guide
 
Unit 2 - Quick Sort.pptx
Unit 2 - Quick Sort.pptxUnit 2 - Quick Sort.pptx
Unit 2 - Quick Sort.pptx
 
Integers
IntegersIntegers
Integers
 

More from SaadMohamedSaad2 (7)

Modeling&Simulation-Template.pdf
Modeling&Simulation-Template.pdfModeling&Simulation-Template.pdf
Modeling&Simulation-Template.pdf
 
IS-Security Projects.pdf
IS-Security Projects.pdfIS-Security Projects.pdf
IS-Security Projects.pdf
 
IS-Security-Template.pdf
IS-Security-Template.pdfIS-Security-Template.pdf
IS-Security-Template.pdf
 
Software Engineering .pptx
Software  Engineering .pptxSoftware  Engineering .pptx
Software Engineering .pptx
 
S.W Project Template2.pdf
S.W Project Template2.pdfS.W Project Template2.pdf
S.W Project Template2.pdf
 
SOFTWARE ENGINEERING.docx
SOFTWARE ENGINEERING.docxSOFTWARE ENGINEERING.docx
SOFTWARE ENGINEERING.docx
 
3-12.pdf
3-12.pdf3-12.pdf
3-12.pdf
 

Recently uploaded

+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+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...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Algorithms Task-4.pdf

  • 3.
  • 5. 5 3 1 9 8 2 4 7 left right pivot Sorting list of Numbers [5, 3, 1, 9, 8, 2, 4, 7]
  • 6. 5 3 1 9 8 2 4 7 left right pivot Comparing left with right and sort small numbers at the left Here, the left and right are already sorted
  • 7. 5 3 1 9 8 2 4 7 left right pivot Algorithm moves forward one position towards left
  • 8. 5 3 1 9 8 2 4 7 left right pivot Doing the same thing to compare left with right and sort small numbers at the left Here, the left and right are not sorted
  • 9. 4 3 1 9 8 2 5 7 right left pivot So, we swap value in the left with its in the right And the pivot stays points at the same value
  • 10. 4 3 1 9 8 2 5 7 right left pivot And then left will move to the next index
  • 11. 4 3 1 9 8 2 5 7 right left pivot Then, we repeat the same steps with each element to get left, right and pivot at the same index. Hence, the element is sorted
  • 12. 4 3 1 2 5 8 9 7 right left pivot Here, (5) is sorted. And we surely know that elements on its left is smaller than its right
  • 13. 1 2 3 4 5 7 8 9 right left pivot We do the same thing recursively to the two left and right sub array of the pivot element until we get the list sorted as seen;