UNB/ CS/ David Bremner/ teaching/ cs3383/ lectures/ 13.1-demos/ quicksort.py
#!/usr/bin/env python3
from partition import partition
from random import randrange

def quicksort(A,p,q):
    if p>=q: return

    r = partition(A,p,q,randrange(p,q))
    quicksort(A,p,r-1)
    quicksort(A,r+1,q)

if __name__ == "__main__":
    from random import choices

    n=11

    A = choices(range(0,100),k=n)
    print("A=",A);

    quicksort(A,0,n-1)
    print("sorted A=",A);