Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 34

curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 50 10 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 10 50 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 10 50 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 10 50 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 10 50 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 10 50 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 10 50 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 10 50 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 10 50 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}
curmax pivot

20 10 50 40 30
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}

swap(array[curmax], array[end])
curmax pivot

20 10 30 40 50
i
pivot = array[end]
curmax = start

for (let i = start; i < end; i++) {


if (array[i] <= pivot) {
swap(array[curmax], array[i]);
curmax++;
}
}

swap(array[curmax], array[end])
curmax pivot SORTED curmax pivot

20 10 30 40 50
i i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


curmax pivot SORTED curmax pivot

20 10 30 40 50
i i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


curmax pivot SORTED curmax pivot

20 10 30 40 50
i i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


curmax pivot SORTED curmax pivot

20 10 30 40 50
i i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


curmax pivot SORTED curmax pivot

20 10 30 40 50
i i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


curmax pivot SORTED curmax pivot

20 10 30 40 50
i i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


curmax pivot SORTED curmax
pivot

20 10 30 40 50
i i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


curmax pivot SORTED curmax
pivot

10 20 30 40 50
i i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


SORTED curmax
pivot

10 20 30 40 50
i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


SORTED curmax
pivot

10 20 30 40 50
i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


SORTED curmax
pivot

10 20 30 40 50
i

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])


SORTED

10 20 30 40 50

pivot = array[end] pivot = array[end]


curmax = start curmax = start

for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
if (array[i] <= pivot) { if (array[i] <= pivot) {
swap(array[curmax], array[i]); swap(array[curmax], array[i]);
curmax++; curmax++;
} }
} }

swap(array[curmax], array[end]) swap(array[curmax], array[end])

You might also like