here is what i have to do:

this is what i have so far.

its pretty much the code in the pdf file with defined functions of quick sort, bubble sort and better bubble sort

im not sure how i implement "size of array increment, and number of test arrays"

can anyone help me?


this is what i have so far:

bubble sort works but i have to enter variable n twice. i need to fix that but dunno how. once thats done, i think bubble sort is finished.

working on better bubble sort but have problems making the function work. :(

any help?

Your function betsort(integer_array) should look like this ...

def betsort(x):
    n = len(x)
    for k in range(n, 1, -1):
        flag = 0
        for i in range(0, k-1):
            if x[i] > x[i+1]:
                swap(x, i, i+1)
                flag = 1
        if flag == 0:

wow it was that simple. thank you very much.

do you know a way i dont have to enter "n = input('enter size of array increment: ')" twice to make it work. i tried different ways, none worked

Put the line

n = input('enter size of array increment: ')

as first item in the loop, right after 'while True:'

Writing your print statement to file:

# open/create text file for writing in main()
fout = open( "test1.txt", "w" )  # may need "a" for append

# in your program under this line
# print '\tn: %d, sort time: %f' % (n, dt)
# add this line
print >>fout, '\tn: %d, sort time: %f' % (n, dt)

# you may have to make 'fout' global or better pass 
# it to your function as argument

thank you very much. works perfectly.

do you know of a way where you ask the user if he/she wants to output it to a file and if so, prompt the user for a filename?

all tries i have done were unsuccessful. it interrupts the program