After heapsort which algorithm comes ?

Also tell which algorithm takes most maximum time and space

Also tell which algorithm takes most maximum time and space

The Gateway to Computer Science Excellence

+1 vote

What is the ascending wise order of sorting algorithms which takes least time and least space to sort the elements?

+1 vote

0

+1

a)if considering only time complexity then merge sort O(n log n)

if considering space complexity then insertion sort because it is inplace algorithm and O(1)

b) insertion sort and quick sort has worst case time complexity of O(n^2) which is think is maximum

and quick sort incase of having ascending order or descending order elements as input forms a skew tree(a chain growing only in one direction)

so in that case spae would be O(n) which i think is maximum because all other sorts are either O(log n) or O(1)

if considering space complexity then insertion sort because it is inplace algorithm and O(1)

b) insertion sort and quick sort has worst case time complexity of O(n^2) which is think is maximum

and quick sort incase of having ascending order or descending order elements as input forms a skew tree(a chain growing only in one direction)

so in that case spae would be O(n) which i think is maximum because all other sorts are either O(log n) or O(1)

0

even over here some people are saying quick sort some are saying merge sort some are saying insertion sort.

The answer is confusing thats why i had asked .

I strictly follow all your rules and regulations and i do not ask here any answer which is already present on google dear sir

hence i request you to please answer my doubt of question

The answer is confusing thats why i had asked .

I strictly follow all your rules and regulations and i do not ask here any answer which is already present on google dear sir

hence i request you to please answer my doubt of question

+1

phd does not imply more knowledge.

As a CS graduate, you should be learning stuff on own and not relying on what others say. This question is against the site policy -- because it is not well defined -- there are many sorting algorithms and one needs to know only the asymptotic complexity at the graduate level.

As a CS graduate, you should be learning stuff on own and not relying on what others say. This question is against the site policy -- because it is not well defined -- there are many sorting algorithms and one needs to know only the asymptotic complexity at the graduate level.

0

yes dear sir so according to asymptotic complexity only tell which is best algorithm and which is worst algorithm with respect to Time complexity ?

(Tell among the algorithms which are covered at graduate level only but aleast tell which is best and which is worst with respect to time complexity )

Dear sir you are my guru , i respect you and thats why i am requesting you to please answer this doubtful question i will be highly oblized to you

(Tell among the algorithms which are covered at graduate level only but aleast tell which is best and which is worst with respect to time complexity )

Dear sir you are my guru , i respect you and thats why i am requesting you to please answer this doubtful question i will be highly oblized to you

0

so from the given table bubble sort is least efficient and

merge sort and heap sort are most efficient and takes least time thats the conclusion ?

merge sort and heap sort are most efficient and takes least time thats the conclusion ?

+1

No that's not the conclusion. Quick sort performs better than both many times. The answer to this question is "it depends". According to the worst case time complexity Merge sort and heap sort wins and also Merge sort is stable.

0

*it depends*

**it depends on what factors please tell ?**

please tell on what basis or grounds or cases the** quick sort is better and performs better many times ?**

0

This comparison is completely about constant factors. In particular, the choice is between a suboptimal choice of the pivot for Quicksort versus the copy of the entire input for Mergesort (or the complexity of the algorithm needed to avoid this copying). It turns out that the Quicksort is more efficient: there's no theory behind this, it just happens to be faster. (Referred from Quora)

0

i am stil not clear with the reason that why Quick sort is better and faster.

please dont copy and paste from quora that i can also do .

if you can please explain with proper reason please tell by giving example

please dont copy and paste from quora that i can also do .

if you can please explain with proper reason please tell by giving example

52,375 questions

60,615 answers

202,051 comments

95,433 users