O(n*n)
Chat with our AI personalities
The complexity of bubble sort is O(n2), also known as exponential complexity. In case this still isn't quite clear, it means that given n elements (for example, 20), it will take, on average, n times n loops (for example, 20 times 20 is 400).
Time complexity gives an indication of the time an algorithm will complete its task. However, it is merely an indication; two algorithms with the same time complexity won't necessarily take the same amount of time to complete. For instance, comparing two primitive values is a constant-time operation. Swapping those values is also a constant-time operation, however a swap requires more individual operations than a comparison does, so a swap will take longer even though the time complexity is exactly the same.
Bubble sort is also known as sinking sort.
If the range of numbers is 1....n and the size of numbers is k(small no.) then the time complexity will be theta n log..
quick sort has a best case time complexity of O(nlogn) and worst case time complexity of 0(n^2). the best case occurs when the pivot element choosen as the center or close to the center element of the list.the time complexity can be derived for this case as: t(n)=2*t(n/2)+n. whereas the worst case time complexity for quick sort happens when the pivot element is towards the end of the list.the time complexity for this can be derived using the recurrence eqn: t(n)=t(n-1)+n
This is false. The movement described is a disadvantageof bubble sort.