@@ -119,14 +119,24 @@ def bubble_sort_recursive(collection: list[Any]) -> list[Any]:
119119 timer_iterative = timeit (
120120 "bubble_sort_iterative(unsorted[:])" , globals = globals (), number = num_runs
121121 )
122- print ("\n Iterative bubble sort:" )
123- print (* bubble_sort_iterative (unsorted ), sep = "," )
124- print (f"Processing time (iterative): { timer_iterative :.5f} s for { num_runs :,} runs" )
122+
123+ print (f"Total runs for benchmark: { num_runs :,} \n " )
124+
125+ # Iterative version
126+ print ("➡️ Iterative Bubble Sort:" )
127+ sorted_iter = bubble_sort_iterative (unsorted )
128+ print ("Sorted Output:" , ", " .join (map (str , sorted_iter )))
129+ print (f"Time Taken (Iterative): { timer_iterative :.5f} s\n " )
130+
131+ # Recursive version
132+ unsorted = sample (range (- 50 , 50 ), 100 )
133+ timer_recursive = timeit (
134+ "bubble_sort_recursive(unsorted[:])" , globals = globals (), number = num_runs
135+ )
136+ print ("➡️ Recursive Bubble Sort:" )
137+ sorted_rec = bubble_sort_recursive (unsorted )
138+ print ("Sorted Output:" , ", " .join (map (str , sorted_rec )))
139+ print (f"Time Taken (Recursive): { timer_recursive :.5f} s" )
140+
141+ print ("\n ✅ Comparison completed successfully!" )
125142
126- unsorted = sample (range (- 50 , 50 ), 100 )
127- timer_recursive = timeit (
128- "bubble_sort_recursive(unsorted[:])" , globals = globals (), number = num_runs
129- )
130- print ("\n Recursive bubble sort:" )
131- print (* bubble_sort_recursive (unsorted ), sep = "," )
132- print (f"Processing time (recursive): { timer_recursive :.5f} s for { num_runs :,} runs" )
0 commit comments