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)
Which are the two standard ways of traversing a graph? i. The depth-first traversal ii. The breadth-first traversal
the voltage wave forms are applied at the inputs of an EX-OR gate. determine the output wave form
Add -75to+25 in 2s complement
representation of linear array
The complexity of searching an element from a set of n elements using Binary search algorithm is O(log n)
A binary search tree (BST), which may sometimes also be named a sorted or ordered binary tree, is an edge based binary tree data structure which has the following functionalities:
Q. Write down an algorithm to convert an infix expression into the postfix expression. Ans. Algo rithm to convert infix expression to post fix expression is given as
Ask consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is repr
What do we mean by algorithm? What are the characteristics of a good and relevant algorithm? An algorithm is "a step-by-step procedure for finishing some task'' An algorithm c
What is complexity of an algorithm? What is the basic relation between the time and space complexities of an algorithm? Justify your answer by giving an example.
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