Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
473 B
3
Indexable
Never
import time
import random

def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        for j in range(0, n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]

if __name__ == "__main__":
    array = random.sample(range(1, 10001), 10000)

    start_time = time.time()

    bubble_sort(array)

    end_time = time.time()

    elapsed_time = end_time - start_time

    print("Tiempo de ejecución:", elapsed_time, "segundos")
Leave a Comment