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)
Define an array. Array is made up of same data structure that exists in any language. Array is set of same data types. Array is the collection of same elements. These same elem
A set s is conveniently shown in a computer store by its characteristic function C(s). This is an array of logical numbers whose ith element has the meaning "i is present in s". As
Hubs - In reality a multiport repeater - Connects stations in a physical star topology - As well may create multiple levels of hierarchy to remove length limitation of 10
write a pseudocode to input the top speed (in km''s/hours) of 5000 cars output the fastest speed and the slowest speed output the average (mean) speed of all the 5000 cars answers
A shop sells books, maps and magazines. Every item is identified by a unique 4 - digit code. All books have a code starting with a 1, all maps have a code which starts with a 2 and
Give the example of bubble sort algorithm For example List: - 7 4 5 3 1. 7 and 4 are compared 2. Since 4 3. The content of 7 is now stored in the variable which was h
A spanning tree of any graph is only a subgraph that keeps all the vertices and is a tree (having no cycle). A graph might have many spanning trees. Figure: A Graph
Suppose that you want to develop a program that accepts a postfix expression and asks values for variables in the expression. Then you need to calculate the answer for the expressi
Q. Write down an algorithm to insert a node in between any two nodes in a linked list Ans. Insertion of a the node after the given element of the listis as follows
A significant aspect of Abstract Data Types is that they explain the properties of a data structure without specifying the details of its implementation. The properties might be im
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