Question: how to calculate time complexity of bubble sort?
Answer: To calculate the complexity of the bubble sort algorithm, it is useful to determine how many comparisons each loop performs. For each element in the array, bubble sort does n − 1 n-1 n−1 comparisons. In big O notation, bubble sort performs O ( n ) O(n) O(n) comparisons.