Which of the following are the worst-case running times of insertion sort, merge sort, and quick sort respectively?
a. O(n^2), O(n log n), and O(n^2)
b. O(nlog(n)), O(nlog(n)), and O(n^2)
c. O(n^2), O(n^2), and O(n log(n))
d. O(n^2), O(n log(n)), and O(n log(n))
Insertion sort takes O(n^2) in worst case, as we need to run two loops. Merge sort takes O (n log(n)) time in all cases. Quick sort takes O(n^2) in worst case.
Computer Science & Information Technology
You might also like to view...
Which of the following firewalls allows an administrator to specify what applications are allowed access?
a. Packet filter firewalls b. Router firewalls c. Stateful inspection firewalls d. Application gateway firewalls
Computer Science & Information Technology
A comment in Java that begins with /** and ends with */ is what kind of comment?
a) block comment b) javadoc comment c) line comment d) nested comment
Computer Science & Information Technology