O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Algorithms Task-4.pdf

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
3-12.pdf
3-12.pdf
Carregando em…3
×

Confira estes a seguir

1 de 14 Anúncio

Mais Conteúdo rRelacionado

Mais recentes (20)

Anúncio

Algorithms Task-4.pdf

  1. 1. Algorithms Task-4 By/ Saad Mohamed Saad
  2. 2. Merge Sort Pseudocode
  3. 3. Quick Sort Problem
  4. 4. 5 3 1 9 8 2 4 7 left right pivot Sorting list of Numbers [5, 3, 1, 9, 8, 2, 4, 7]
  5. 5. 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
  6. 6. 5 3 1 9 8 2 4 7 left right pivot Algorithm moves forward one position towards left
  7. 7. 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
  8. 8. 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
  9. 9. 4 3 1 9 8 2 5 7 right left pivot And then left will move to the next index
  10. 10. 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
  11. 11. 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
  12. 12. 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;
  13. 13. Thank You Any Question.?

×