answersLogoWhite

0


Best Answer

O(n*n)

User Avatar

Parker Braun

Lvl 10
2y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

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).

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

The cyclomatic complexity of bubble sort is 4.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

(n(n+1)) / 2

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

O(n^2)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is time complexity of bubble sort?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you find the time complexity of a given algorithm?

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.


What is the time complexity of radix 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..


What is another name for bubble sort?

Bubble sort is also known as sinking sort.


How do you select pivot in quick sort?

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


Is it trueThe biggest advantage of the bubble sort algorithm is that values move only by one element at a time toward their final destination in the array?

This is false. The movement described is a disadvantageof bubble sort.

Related questions

What is complex sort?

Time complexity Best case: The best case complexity of bubble sort is O(n). When sorting is not required, all the elements are already sorted. Average case: The average case complexity of bubble sort is O(n*n). It occurs when the elements are jumbled, neither properly ascending nor descending. Worst case: The worst-case complexity of bubble sort is O(n*n). It occurs when the array elements are needed to be sorted in reverse order. Space complexity In the bubble sort algorithm, space complexity is O(1) as an extra variable is needed for swapping.


How do you find the time complexity of a given algorithm?

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.


What is the time complexity of radix 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..


What is another name for bubble sort?

Bubble sort is also known as sinking sort.


How do you select pivot in quick sort?

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


Is it trueThe biggest advantage of the bubble sort algorithm is that values move only by one element at a time toward their final destination in the array?

This is false. The movement described is a disadvantageof bubble sort.


Time and space complexities of various sorting methods?

Bubble sort-O(n*n)-in all cases Insertion sort-O(n*n)-in avg and worst case in best case it is O(logn) Quick Sort-0(nlogn)-in avg n best case and 0(n*n)-in Worst case selection sort-same as bubble Linear search-o(n) Binary Search-o(nlog) Any doubt mail me-jain88visionary@rediffmail.com


What are some potential inefficiencies when using the bubble sort algorithm?

Although bubble sort is one of the simplest sorting algorithms to understand and implement, its O(n2)complexity means it is far too inefficient for use on lists having more than a few elements. Even among simple O(n2)sorting algorithms, algorithms like insertion sort are usually considerably more efficient.


Why quick sort better than merge sort?

it has less complexity


What is the complexity of bucket sort?

o(n)


Is selection sort and tournament sort are same?

No. Tournament sort is a variation of heapsort but is based upon a naive selection sort. Selection sort takes O(n) time to find the largest element and requires n passes, and thus has an average complexity of O(n*n). Tournament sort takes O(n) time to build a priority queue and thus reduces the search time to O(log n) for each selection, and therefore has an average complexity of O(n log n), the same as heapsort.


What are the advantages for bubble sort?

Bubble sort has no practical applications other than that it is often cited as an example of how not to write an algorithm. Insert sort is the best algorithm for sorting small lists of items and is often used in conjunction with quick sort to sort larger lists. Like insert sort, bubble sort is simple to implement and is a stable sort (equal items remain in the same order they were input). However, insert sort uses copy or move operations rather than swaps (which is actually three operations per swap) and is therefore quicker. The only time a bubble sort will work quicker than insert sort is when the array is already sorted, which renders the entire algorithm redundant. A modified algorithm that specifically tests if an array is sorted or not would be more efficient than a single-pass bubble sort.