Welcome! Log In Create A New Profile

Advanced

Quicksort - assignment 2 solution?

Posted by BenVP 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar Quicksort - assignment 2 solution?
October 13, 2010 01:59PM
Can someone please explain to me how they managed to get their answer to 3b)?

Did they swap the middle pivot with the first element, sort the lower sublist,
and then replace the middle pivot?

Or did they just start swaping elements according to the pivot,
finding the middle pivot of the lower sublist and sorting those elements.

When I did it this way in the assignment: finding the middle pivot, swapping the elements,
then partitioning the list and repeating the process, it was marked wrong.

I have gone through the text book and various other websites which explain the quicksort algorithm,
I still can't figure out how they got their answer.

Any help would be welcome,

Ben
Re: Quicksort - assignment 2 solution?
October 14, 2010 07:16AM
I'm similarly confused. Is answer 3 c) for Tut202 also blank for you?
avatar Re: Quicksort - assignment 2 solution?
October 14, 2010 11:39AM
Not only is 3c) missing, if you look closely 3b is the answer to semester 1's question.
At least they gave us the initial list inside the table.
avatar Re: Quicksort - assignment 2 solution?
October 14, 2010 01:07PM
I've been tracking their solution to first semester's solution but I'm getting stuck somewhere down the line. On the fourth row from the top. Can someone please quicksort this list for just one partition:

6 7 4 5 3

Please show step by step. Because I am coming up with 3 7 4 5 6 in the end
Re: Quicksort - assignment 2 solution?
October 15, 2010 11:49AM
6 7 4 5 3
The pivot is 4: swap(pivot, 1st)

4 7 6 5 3
smallIndex = position 0, index start at 1, increment index looking for elem < pivot. That is at position 4.
increment smallIndex (pos 1), then swap(smallIndex,index)

4 3 6 5 7

swap(pivot,smallIndex), smallIndex is in pos 1

3 4 6 5 7
avatar Re: Quicksort - assignment 2 solution?
October 15, 2010 01:16PM
Thanks sombu,
from your posting I figured out how to do quicksort.

Regards,
Ben
Re: Quicksort - assignment 2 solution?
October 17, 2010 01:04PM
I got my assignment scripts back but have queries. Assignment2 Q3c) the Mergesort diagram does not have values(is blank) but the softcopy(PDF) that I used to upload on MyUnisa has values. I have actually attached it on email to someone and was it was transimitted and downloaded fine, with Q3c) diagram with vaues. I have lost marks on this question. I do not know what happened on myUnisa?

Also assigment 1 , the marker made a mistake in adding up marks s/he had awarded each answer.

Please lecturers respond!!!
Sorry, only registered users may post in this forum.

Click here to login