The Procedure
Real Lab Procedure
- It stores the elements to be sorted in a list / array named "data".
- "size" variable is used to hold the length of the input list.
- Quick Sort is performed using quickSort(), in which, list name, lower and upper index of list are passed as arguments.
- Repeat steps 5 to 12 until the data gets sorted.
- Find the "pivot" element such that the element smaller than "pivot" is on the left and the element greater than "pivot" is on the right.
- Last element is considered as "pivot" here.
- Variable "i" pointed to elements higher than "pivot".
- It traverses through all elements and compares each element with "pivot".
- If an element smaller than "pivot" is found then swap it with the greater element pointed by "i".
- Swapping element at "i" with element at "j".
- Swap the "pivot" element with greater element indicated by "i".
- Return the position from where partition is done.
- Print the sorted array.
Simulator Procedure
- Select the variables from the dropdown list.
- Click on the Finish button or Start button to view the state diagram.
- If you have clicked on the Start button then use Next and Previous button to view the State diagram.
- Click on the Reset button when the State diagram is completed to redo the procedure.