Answers for "How many iterations will be required to sort the following array, arr={4,5,7,6} using bubble sort algorithm?"

13

bubble sort python

def bubbleSort(lis):
    length = len(lis)
    for i in range(length):
        for j in range(length - i):
            a = lis[j]
            if a != lis[-1]:
                b = lis[j + 1]
                if a > b:
                    lis[j] = b
                    lis[j + 1] = a
    return lis
Posted by: Guest on May-28-2020
0

bubble sort in python

def bubbleSort(lis):
    length = len(lis)
    for i in range(length):
        for j in range(length - i):
            a = lis[j]
            if a != lis[-1]:
                b = lis[j + 1]
                if a > b:
                    lis[j] = b
                    lis[j + 1] = a
    return lis
Posted by: Guest on August-26-2020

Code answers related to "How many iterations will be required to sort the following array, arr={4,5,7,6} using bubble sort algorithm?"

Python Answers by Framework

Browse Popular Code Answers by Language