Partition algorithm problem

Diskussionen und Austausch über die von FPDF bereitgestellten Methoden, Problemen bei der Anwendung etc.
Beiträge: 2
Registriert: Fr 3. Nov 2017, 13:39

Partition algorithm problem

Beitragvon JoeClark » Mi 8. Nov 2017, 11:51

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.

[Links deleted]

Beiträge: 1492
Registriert: Do 22. Jun 2006, 18:23

Re: Partition algorithm problem

Beitragvon Wirus! » Mi 8. Nov 2017, 13:11

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.

Zurück zu „Programmierung“

Wer ist online?

Mitglieder in diesem Forum: Bing [Bot], Google [Bot] und 0 Gäste