DIR Return Create A Forum - Home
---------------------------------------------------------
Class H22
HTML https://classh22.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: exercises
*****************************************************
#Post#: 57--------------------------------------------------
quick sort - psaudo code
DIR By: SpiderGoat
Date: April 4, 2014, 12:40 am
---------------------------------------------------------
well, guys,
i think i got it, but i can't be sure 'till i write it down.
does this make any reason to any?
--- Code ---
quicky(adressOfFirst as Array, sizeOfPatial)
if size is smaller than 2, return
//exit - 1 item is sorted
if Array[1] < Array[0]
// for 2 cases: only 2 items, more than 2 items and
next after the first is smaller than the first
{
swap and call quicky( address + 1, size -1)
return // let the other next calls do the job.
unless, it may continue to next if
}
if size > 2
{
Lindex is [1] and Rindex is [2]
while (Rindex <= (size-1))
{
if R is smaller than L (values)
swap L and R values
call quicky(Lindex, size of Rindex-Lindex)
// Lindex becomes a pivot for left side
call quicky(Rindex, size of size-Rindex)
// Rindex becomes a pivot for right side
break;
}
}
return
}
--- End Code ---
*****************************************************
Page 1 of 1