A list is ordered from smaller to largest when a sort is
called. Which sort would take the shortest time to execute?

Answer Posted / soumitra biswas

modified bubble sort with flag.As the array is already sorted
there will be no swapping in first pass,so no comparison
will take place after first pass and program stops executing.
time complexity =0(n).

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you find the index of an element in an arraylist?

526


Is a hashset ordered?

574


Which is better array or linked list?

568


What is space complexity of a program?

540


Mention for which header list, you will found the last node contains the null pointer?

573






How do you find the complexity of a bubble sort?

546


What is array and its types in data structure?

583


What is two-dimensional array?

607


What is a list in data structure?

534


Define a linear and non linear data structure.

587


Which is better stack or queue?

531


Define data type and what are the types of data type?

623


Can hashmap have duplicate keys?

578


Can arraylist store primitives?

537


What is a vector class?

560