CUSTOMER_CODE SMUDE DIVISION_CODE SMUDE EVENT_CODE JAN2016 ASSESSMENT_CODE BT0080_JAN2016 QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 6511 QUESTION_TEXT Explain the Specification Method for Algorithm? SCHEME OF EVALUATION An algorithm is a description statement of a sequence of activities that constitute a process of getting desired output from the given inputs. Such description or statement needs to be specified in some notation or language. We briefly mentioned about some possible notations for the purpose. Three well – know notations/ languages used mostly for the purpose are enumerated below. a.Natural Language (NL): An NL is highly expressive in the sense that it can express algorithms of all types of computable problems. However, main problem with an NL is the inherent ambiguity, i.e., a statement or description in NL may have many meaning, which, may be unintended and misleading 5 mark. b.A Pseudo code notation is a sort of dialect obtained by mixing some programming language constructs with natural language descriptions of algorithms. The pseudo-code method of notation is the frequently used one for expressing algorithms. However, there is no uniform/ standard pseudo-code notation used for the purpose, though, most pseudo-code notations are quite similar to each other. c.Flow chart is a method of expressing algorithms by a collection of geometric shapes with imbedded descriptions of algorithmic steps. However, the technique is found to be too cumbersome, specially, to express complex algorithms.5 mark QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 73600 QUESTION_TEXT Write an algorithm for merge sort. SCHEME OF EVALUATION Merge sort (5 marks) 1. Algorithm MergeSort (low, high) 2. //a[low:high] is a global array to be sorted. 3. //small (P) is true if there is only one element 4. //to sort. In this case the list is already sorted. 5. { 6. if (low< high > then //If there are more than one element 7. { 8. //Divide P into sub problems 9. //Find where to split the set 10. mid:= [(low+high)/2] 11. //Solve the sub problems 12. MergeSort (low,mid); 13. MergeSort(mid+1, high); 14. //combine the solutions 15. Merge(low, mid, high) 16. } 17. } Merge (5 marks) Algorithm Merge (low, mid, high) //a{low: high] is a global array containing two sorted //subsets in a [low: mid} and in a [mid+1 high]. The //goal is to merge these two sets into a single set residing //in a [low: high],b[J is an auxiliary global array. { h:=low; i:low; j:=mid+1; while ((h ≤ mid) and (j≤ high)) do { If (a[h]≤ a[j]) then { b[i] : a[h]; h:—Th+1; } Else { b[i]:=a[j]; j:=j+ 1; } i:i+1; } If (h >mid) then Fork=jto high do { b[i]:=a[k]; i:i+ 1; } Else For k:=h to mid do { b[i]:=a[k]; i:i+1; } For k:=lowto high do a[k]:=b[k]; } QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 125572 QUESTION_TEXT Prove the theorem “A given connected graph G is a Euler graph if and only if all the vertices of G are of even degree”. Proof: Direct part: suppose G is a Euler graph. Then G contains a Euler line. So there exists a closed walk running through all the edges of G exactly once ……. (5 marks) SCHEME OF EVALUATION Converse: Suppose all the vertices of G are of even degree, now to show that G is a Euler graph, we have to construct a closed walk starting at an arbitrary vertex v and running through all the edges of G exactly once …… (5 marks) QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 125573 QUESTION_TEXT Discuss backtracking strategy. Give an algorithm for N-queens problem. Backtracking Technique explanation (3 marks) Algorithm N–Queens problems Algorithm N Queens (k, n) { For I:= 1 to n do { If place (k, j) then SCHEME OF EVALUATION { X[k]:=i; If (k=n) then write [x[1:n]] Else Nqueen (k+1, n); } } } Algorithm place (k, i) { for (i:=i) to (k–1) do if ((x[j]–I or Abs (x[j] = Abs (j–k))) then return false return true } (7 marks) QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 125575 QUESTION_TEXT Explain Euclid’s Algorithm for finding G.C.D of two Natural Numbers. SCHEME OF EVALUATION i. ii. iii. Divide m by n and let r be the new remainder. If r = 0, the algorithm terminates and n is the answer otherwise. (Interchange) let the new value of m be the current value of n and the new value of n be the current value of r. Go back to step (i) r must be equal to zero in finite number of steps (i) (ii) and (iii) QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 125577 QUESTION_TEXT Explain the different category of problems. i. ii. iii. SCHEME OF EVALUATION iv. v. Problems which cannot even be defined formally Problems which can be formally defined but cannot be solved by computational means. Problems which though theoretical can be solved by computational means, yet are infeasible. Problems that are called feasible or theoretically not difficult to solve by computational means. Last but probably most interesting class includes large number of problems, for each of which, it is not known whether it is in P or not in P. (2 5 = 10 marks)