Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
1.6k views
in Computer by (69.8k points)

How do you calculate the complexity of sorting algorithms? Find the complexity of Insertion sort and Bubble Sort. 

1 Answer

+1 vote
by (69.2k points)
selected by
 
Best answer

The complexity of sorting algorithms depends on the input: sorting a thousand numbers takes longer than sorting three numbers. The best notion of input size depends on the problem being studied. For sorting algorithms, the most natural measure is the number of items in the input that is array size n. We start by associating time “cost” of each statement and the number of times each statement is executed assuming that comments are not executable statements, and so do not take any time. 

Complexity of Bubble sort: O(n2

Complexity of Insertion sort: O(n2

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...