Question DSA-SORT-0001
EasyWhat is the worst-case time complexity of bubble sort?
- A.
O(n log n)
- B.
O(n²)
- C.
Show answer and explanation
Answer: B
Each of up to n passes compares adjacent pairs across the array.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Sorting question
What is the worst-case time complexity of bubble sort?
O(n log n)
O(n²)
Answer: B
Each of up to n passes compares adjacent pairs across the array.
O(log n)
O(n)