0% found this document useful (0 votes)
95 views4 pages

MC0080-Analysis and Design of Algorithm

The document describes answers to multiple questions related to algorithms and data structures. It discusses sorting algorithms like insertion sort, bubble sort, selection sort, and heap sort. It also covers divide and conquer techniques like merge sort and quick sort. Other topics summarized include asymptotic notation, Fibonacci heaps and binomial heaps, Strassen's matrix multiplication algorithm, greedy algorithms and their formulation, and Prim's minimum spanning tree algorithm.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views4 pages

MC0080-Analysis and Design of Algorithm

The document describes answers to multiple questions related to algorithms and data structures. It discusses sorting algorithms like insertion sort, bubble sort, selection sort, and heap sort. It also covers divide and conquer techniques like merge sort and quick sort. Other topics summarized include asymptotic notation, Fibonacci heaps and binomial heaps, Strassen's matrix multiplication algorithm, greedy algorithms and their formulation, and Prim's minimum spanning tree algorithm.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MC0080- Analysis and Design of Algorithm

Q1 Describe the following: (A) Well known Sorting Algorithms (B) Divide and Conquer Techniques
Ans 1(A) They are following:- insertion sort, bubble sort, selection sort, shell sort, heap sort well known Sorting Algorithms:Insertion sort:- It helps in sorting a list L of n numbers represented by an array A[1.....n] proceeds by picking up the numbers in the array from left one by one and each newly picked up number is placed at its relative position, w.r.t. the sorting order, among the earlier ordered ones

1. Bubble sort:- It helps in sorting a list L of n numbers represented by an array A[1.....n], proceeds by scanning the array from left to right. At each stage, compares adjacent pairs of numbers at positions A[i] and A[i+1] and whenever a pair of adjacent numbers is found to be out of order, then the positions at the numbers are exchanged. 2. Selection sort:- It is used for sorting a list L of n numbers, represented by an array A[1..n], proceeds by finding the maximum element of the array and placing it in the last position of the array representing the list. 3. Shell sort:- It is named so in honour of D.L short, who suggested the algorithm. It is also called diminishing- increment sort. 4. Heap sort:- Heap construction for a given array. Copy the root value to right-most yet-to-be occupied location of the array used to store the sorted values and copy the value in the last node of the tree to the root.
Ans 1(B) Divide and Conquer Techniques

1. Merge sort:- We recursively chop the list into two sub lists of almost equal sizes and when we get lists of get lists one, then start sorted merging of lists in the reverse order in which these lists were obtained through chopping. 2. Quick sort:- It is also called divide and conquer method of sorting. This method does more work in the first step of portioning the list into two sub lists. Then combining the two lists becomes trivial.

Q2. Explain in your own words the different asymptotic functions and notations.
Ans 2. The purpose of these asymptotic growth rate functions to be introduced is to facilitate the recognition of essential character of a complexity function through some simpler functions delivered by these notations. For example:- a complexity function ( ) + + , has essentially same ( ) behaviour as that of as the problem size n becomes larger and larger.

The Notation It provides asymptotic upper bound for a given functions each from the set of natural numbers or set of natural numbers or set of positive real numbers to positive real numbers

Q3 Describe the following: (A) Fibonacci Heaps (B) Binomial Heaps


Ans 3(A) 1. Structures of Fibonacci heap:- Like a binomial heap, a Fibonacci heap is a collection of min-heap-ordered trees, the trees in a Fibonacci heap are not constrained to be binomial trees. Unlike trees within binomial heaps, which are ordered, trees within Fibonacci heaps are rooted but unordered. The root of all the trees in a Fibonacci heap is linked together using their left and right pointers into a circular, doubly linked list called the root list of the Fibonacci heap. The pointer min [H] thus points to the node in the root list whose key is minimum. The order of the trees within a root list is arbitrary. 2. Potential function:- For a given Fibonacci heap H, we indicate by t(H) the numbers of trees in the root list of H and by m(H) the number of marked nodes in H. 3. Maximum potential:- The amortized analyses we shall perform in the remaining sections of this unit assume that there is a known upper bound D(n) on the maximum degree Ans 3(B) Binomial Heaps A binomial heap H is a set of binomial trees that satisfies the following heap properties. 1. Each binomial tree in H obeys the min-heap property: the key of a node is greater than or equal to the key of its parent. 2. For any non negative integer k, there is at most one binomial tree in H whose root has degree

Q4. Discuss the process of flow of Strassens Algorithm and also its limitations.
Ans 4 The recursive algorithm for multiplying nn matrices is given below: 1. Partition the two matrices A, B into matrices 2. Conquer: Perform 7 multiplications recursively. 3. Combine: Form using + and . The current best upper bound for multiplying matrices is approximately Limitations of Strassens Algorithm From a practical point of view, Strassens algorithm is often not the method of choice for matrix multiplication, for the following four reasons: 1. The constant factor hidden in the running larger than the constant factor in the method. time of Stassens algorithm is

2. When the matrices are sparse, methods tailored for sparse matrices are faster.

3.

Stassens algorithm is not quite as numerically stable as the navemethod.4. The sub matrices formed at the levels of recursion consume space

4. The sub matrices formed at the levels of recursion consume space.

Q.5 How do you formulize a greedy technique? Discuss the different steps one by one?
Ans 5 Set of Considered and Rejected Values:

As the name suggests, this is the set of all those values, which are considered but rejected. Let us call this set as RV : Set of considered and Rejected Values A candidate value may belong to both CV and RV. But, once a value is put in RV, then this value cannot be put any more in CV. For example, to make an amount of Rs. 289, once we have chosen two notes each of denomination100, we have CV = {100, 100}At this stage, we have collected Rs. 200 out of the required Rs. 289. At this stage RV = {1000, 500}. So, we can chose a note of any denomination except those in RV, i.e., except 1000 and 500. Thus, at this stage, we can choose a note of denomination 100. Selection Function Self Finds out the most promising candidate value out of the values not yet rejected. In the case of Minimum Number of Notes problem, for collecting Rs. 289, at the stage when RV = {1000, 500} and CV = {100, 100} then first the function Self attempts the denomination 100. But, through function Self, when it is found that by addition of 100 to the values already in CV, the total value becomes300 which exceeds 289, the value 100 is rejected and put in RV. Next, the function Self attempts the next lower denomination 50. The value 50 when added to the sum of values in CV gives 250, which is less than 289. Hence, the value 50 is returned by the function Self. The Feasibility-Test Function, say FeaF. When a new value say v is chosen by the function Self, then the function FeaF checks whether the new set, obtained by adding v to the set CV of already selected values, is a possible part of the final solution. Thus in the case of Minimum Number of Notes problem, if amount to be collected isRs. 289 and at some stage, CV = {100, 100}, then the function SelF returns50. At this stage, the function FeaF takes the control. It adds 50 to the sum of the values in CV, and on finding that the sum 250 is less than the required value 289 informs the main/calling program that{100, 100, 50} can be a part of some final solution, and needs to be exploredfurther.vii) The Objective Function, say ObjF, gives the value of the solution. For example, in the case of the problem of collecting Rs. 289; asCV = {100, 100, 50, 20, 10, 5, 2, 2} is such that sum of values in CV equals the required value 289, the function ObjF returns the number of notes in CV,i.e., the number 8.After having introduced a number of sets and functions that may be required by an algorithm based on greedy technique, we give below the outline of greedy technique, say Greedy-Structure. For any actual algorithm based on greedy technique, the various structures the functions discussed above have to be replaced by actual functions. These functions depend upon the problem under consideration. The Greedy-Structure outlined below takes the set GV of given values as input parameter and returns CV, the set of chosen values. For developing any algorithm based on greedy technique, the following function outline will be used.

Q6 Briefly explain the Prims algorithm.


Ans 6 Builds up a minimum spanning tree by adding edges to form a sequence of expanding sub trees. Initially, the sub tree, in the sequence, consists of just a single vertex which is selected arbitrarily from the set V of vertices of the given graph. The sub tree is built-up iteratively by adding an edge that has minimum weight among their main edges (i.e., edge selected greedily) and, which at the same time, does not form a cycle with the earlier selected edges. Algorithm Spanning-Prim (G) // the algorithm constructs a minimum spanning tree// for which the input is a weighted connected graph G = (V, E)// the output is the set of edges, to be denoted by E T , which together constitute a minimum spanning tree of the given graph G// for the pair of vertices that are not adjacent in the graph to each other, can be given

You might also like