Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions code_to_optimize/bubble_sort_codeflash_trace.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from codeflash.benchmarking.codeflash_trace import codeflash_trace


@codeflash_trace
def sorter(arr):
for i in range(len(arr)):
Expand All @@ -9,6 +11,7 @@ def sorter(arr):
arr[j + 1] = temp
return arr


@codeflash_trace
def recursive_bubble_sort(arr, n=None):
# Initialize n if not provided
Expand All @@ -27,18 +30,15 @@ def recursive_bubble_sort(arr, n=None):
# Recursively sort the remaining n-1 elements
return recursive_bubble_sort(arr, n - 1)


class Sorter:
@codeflash_trace
def __init__(self, arr):
self.arr = arr

@codeflash_trace
def sorter(self, multiplier):
for i in range(len(self.arr)):
for j in range(len(self.arr) - 1):
if self.arr[j] > self.arr[j + 1]:
temp = self.arr[j]
self.arr[j] = self.arr[j + 1]
self.arr[j + 1] = temp
self.arr.sort()
return self.arr * multiplier

@staticmethod
Expand Down
Loading