Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Assume that the algorithms considered here so... Start Learning for Free
Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?
I. Quicksort runs in Θ(n2) time
II. Bubblesort runs in Θ(n2) time
III. Mergesort runs in Θ(n) time
IV. Insertion sort runs in Θ(n) time
  • a)
    I and II only
  • b)
    I and III only
  • c)
    II and IV only
  • d)
    I and IV only
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
Assume that the algorithms considered here sort the input sequences in...
I. Given an array in ascending order, Recurrence relation for total number of comparisons for quicksort will be T(n) = T(n-1)+O(n) //partition algo will take O(n) comparisons in any case. = O(n^2)
II. Bubble Sort runs in Θ(n^2) time If an array is in ascending order, we could make a small modification in Bubble Sort Inner for loop which is responsible for bubbling the kth largest element to the end in kth iteration. Whenever there is no swap after the completion of inner for loop of bubble sort in any iteration, we can declare that array is sorted in case of Bubble Sort taking O(n) time in Best Case.
III. Merge Sort runs in Θ(n) time Merge Sort relies on Divide and Conquer paradigm to sort an array and there is no such worst or best case input for merge sort. For any sequence, Time complexity will be given by following recurrence relation, T(n) = 2T(n/2) + Θ(n) // In-Place Merge algorithm will take Θ(n) due to copying an entire array. = Θ(nlogn)
IV. Insertion sort runs in Θ(n) time Whenever a new element which will be greater than all the elements of the intermediate sorted sub-array (because given array is sorted) is added, there won't be any swap but a single comparison. In n-1 passes we will be having 0 swaps and n-1 comparisons. Total time complexity = O(n) // N-1 Comparisons
//// For an array already sorted in ascending order, Quicksort has a complexity Θ(n2) [Worst Case] Bubblesort has a complexity Θ(n) [Best Case] Mergesort has a complexity Θ(n log n) [Any Case] Insertsort has a complexity Θ(n) [Best Case] 
View all questions of this test
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer?
Question Description
Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer?.
Solutions for Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer?, a detailed solution for Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer? has been provided alongside types of Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE ?I. Quicksort runs in Θ(n2) timeII. Bubblesort runs in Θ(n2) timeIII. Mergesort runs in Θ(n) timeIV. Insertion sort runs in Θ(n) timea)I and II onlyb)I and III onlyc)II and IV onlyd)I and IV onlyCorrect answer is option 'D'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev