def run(a, prt=sys.stdout): desc = 'QUICKSORT PARTITION' ah = ArrayHistory() j = _partition(a, lo=0, hi=len(a)-1, array_history=ah) ah.prt() ah.show(desc) print desc, "RESULT:", ' '.join(str(e) for e in a)
def run(a): desc = 'QUICKSORT' ah = ArrayHistory() Sort(a, array_history=ah) ah.prt() ah.show(desc) print(desc, "RESULT:", a)
def run(a): desc = 'QUICKSORT' ah = ArrayHistory() Sort(a, array_history=ah) ah.prt() ah.show(desc) print desc, "RESULT:", a
def run(a, prt=sys.stdout): desc = 'QUICKSORT PARTITION' ah = ArrayHistory() j = _partition(a, lo=0, hi=len(a)-1, array_history=ah) ah.prt() ah.show(desc) print(desc, "RESULT:", ' '.join(str(e) for e in a))
def run(a, desc=None, prt=sys.stdout): ah = ArrayHistory() Sort(a, array_history=ah) if desc is None: desc = "INSERTION SORT" prt.write("{DESC} RESULT {A}\n".format(DESC=desc, A=' '.join(str(e) for e in a))) ah.prt() ah.show(desc)
def run(a, desc=None, sort_seq=None, prt=sys.stdout): ah = ArrayHistory() Sort(a, array_history=ah, sort_seq=sort_seq) if desc is None: desc = "SHELL SORT" prt.write("{DESC} RESULT {A}\n".format(DESC=desc, A=' '.join(str(e) for e in a))) ah.prt() ah.show(desc)
def test_wk2_q2a(prt=sys.stdout): desc = 'SELECTION SORT WORDS' prt.write("\n{TEST}\n".format(TEST=desc)) exp = "BECK BUSH DEVO EVE6 HOLE JAYZ KORN MIMS VAIN RATT TOTO PINK SADE NOFX SOAD WHAM" a = "HOLE BUSH MIMS BECK WHAM SOAD NOFX TOTO VAIN RATT DEVO PINK SADE KORN JAYZ EVE6".split() ah = ArrayHistory() Sort(a, array_history=ah) ah.show(desc) for idx, A in enumerate(ah): if chk( A[0], exp ): prt.write("MATCH {I}\n".format(I=idx))
def test_wk2_q2a(prt=sys.stdout): desc = 'SELECTION SORT WORDS' prt.write("\n{TEST}\n".format(TEST=desc)) exp = "BECK BUSH DEVO EVE6 HOLE JAYZ KORN MIMS VAIN RATT TOTO PINK SADE NOFX SOAD WHAM" a = "HOLE BUSH MIMS BECK WHAM SOAD NOFX TOTO VAIN RATT DEVO PINK SADE KORN JAYZ EVE6".split( ) ah = ArrayHistory() Sort(a, array_history=ah) ah.show(desc) for idx, A in enumerate(ah): if chk(A[0], exp): prt.write("MATCH {I}\n".format(I=idx))
def test_2(): # Keys are 'A' and 'B': a = [ {'B':1}, {'B':2}, {'B':3}, {'B':4}, {'B':5}, {'A':1} ] ah = ArrayHistory() Sort(a, array_history=ah) ah.show('SHELL')
def test_2(): # Keys are 'A' and 'B': a = [{'B': 1}, {'B': 2}, {'B': 3}, {'B': 4}, {'B': 5}, {'A': 1}] ah = ArrayHistory() Sort(a, array_history=ah) ah.show('SHELL')