Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Q. Calculate that how many key comparisons and assignments an insertion sort makes in its worst case?
Ans:
The worst case performance occurs in insertion sort occurs when the elements of the input array are in descending order. In that case, the first pass requires one comparison, the second pass requires two comparisons, third pass three comparisons till the kth pass requires (k-1), and in the end the last pass requires (n-1) comparisons. Therefore, we obtain the total numbers of comparisons as follows : f(n) = 1+2+3+.........+(n-k)+.....+(n-2)+(n-1) = n(n-1)/2 = O(n2)
The worst case performance occurs in insertion sort occurs when the elements of the input array are in descending order. In that case, the first pass requires one comparison, the second pass requires two comparisons, third pass three comparisons till the kth pass requires (k-1), and in the end the last pass requires (n-1) comparisons. Therefore, we obtain the total numbers of comparisons as follows :
f(n) = 1+2+3+.........+(n-k)+.....+(n-2)+(n-1)
= n(n-1)/2
= O(n2)
Comparison Techniques There are several techniques for determining the relevancy and relative position of two polygons. Not all tests may be used with all hidden-surface algori
explain the determination of interest rate in the classical system.
Example 1: Following are Simple sequence of statements Statement 1; Statement 2; ... ... Statement k; The entire time can be found out through adding the times for
Q. Develop a representation for a list where insertions and deletions can be done at either end. Such a structure is known as a Deque (Double ended queue). Write functions for inse
Explain Floyd's algorithm It is convenient to record the lengths of shortest paths in an n by n matrix D known as the distance matrix: the element d ij in the i th row an
The data structure needed for Breadth First Traversal on a graph is Queue
Technique for direct search is Hashing is the used for direct search.
i:=1 while(i { x:=x+1; i:=i+1; }
What values are automatically assigned to those array elements which are not explicitly initialized? Garbage values are automatically assigned to those array elements that
Determine about the unreachable code assertion An unreachable code assertion is an assertion that is placed at a point in a program that shouldn't be executed under any circum
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd