Seite 1 von 1

Partition algorithm problem

Verfasst: Mi 8. Nov 2017, 11:51
von JoeClark
I need help to solve this algorighm.
1. Let p be the position in the array such that a[p] is the median
of a[left], a[m], and a[right] (where m is about midway
between left and right).
2. If p is not equal to left, swap a[p] and a[left].
3. Set pivot to a[left].
4. Set i = left + 1 and j = right.
5. While i ≤ j, repeat:
5.1. While i ≤ j and a[i] ≤ pivot, increment i.
5.2. While j ≥ i and a[j] ≥ pivot, decrement j.
5.3. If i < j, swap a[i] and a[j].
6. If j * left, set a[left] to a[j], and a[j] to pivot.
7. Terminate with answer j.
I know how to solve steps 2-7, step number 1 is a bit tricky.But A small part i was able to solve(i think) Can someone get me any clues at all please?



I didn't find the right solution from the internet.

References:
[Links deleted]

Re: Partition algorithm problem

Verfasst: Mi 8. Nov 2017, 13:11
von Wirus!
Due this is a german forum - please post in german language
There is also no relation to FPDF or even PDF - the target of this page, so your "reference" links are deleted.