Starting from:
$30

$24

Lab 9: QuickSort, Hanoi Solution




This is an optional lab: if done, I will use this to replace your lowest lab.

If not done, there is no deleterious effect on your grade.




Submit (arg=9) lab9.py by 1159pm Tuesday which will contain three functions:

1. quicksort (as spec'd in lab8)

2. partition (required by quicksort, as spec'd in lab8)

3. hanoi:




def hanoi(n,start,tmp,final):

if n 0:

hanoi(n - 1,...)

final.append(start.pop())

hanoi(n - 1,...)

print start,tmp,final

return True

else:

return True




(as described in class: you just need to complete the ...)




where start, tmp, and final will be lists e.g., for n = 3:

start = [1,2,3]

tmp = []

final = []




after running hanoi:

final = [1,2,3]

tmp = []

start = []




You should not need any helpers, but if you include them in the file

(prefixed by helper_<yourfname) there will be no problem.

More products