DAA ADA Viva Questions

April 2, 2018 | Author: Abhishek Manjunath | Category: Dynamic Programming, Time Complexity, Computational Complexity Theory


Comments



Description

Viva Questions1) What is the time complexity of linear search? Θ(n) 2) What is the time complexity of binary search? Θ(log2n) 3) What is the major requirement for binary search? The given list should be sorted. 4) What is binary search? It is an efficient method of finding out a required item from a given list, provided the list is in order. The process is: 1. 2. 3. 4. First the middle item of the sorted list is found. Compare the item with this element. If they are equal search is complete. If the middle element is greater than the item being searched, this process is repeated in the upper half of the list. 5. If the middle element is lesser than the item being searched, this process is repeated in the lower half of the list. 5) What is parental dominance? The key at each node is greater than or equal to the keys at its children. 6) What is heap? A heap can be defined as a binary tree with keys assigned to its nodes ( one key per node) provided the following two conditions are met: 1 The tree’s shape requirement – The binary tree is essentially complete ( or simply complete), that is, all its levels are full except possibly the last level, where only some rightmost leaves may be missing. 2. The parental dominance requirement – The key at each node is greater than or equal to the keys at its children. MCA | Collections: http://srinivas-rangan.blogspot.in/p/mca-study-materials.html 1 14) When do you say an algorithm is stable and in place? Stable – if it retains the relative ordering.7) What is height of Binary tree? It is the longest path from the root to any leaf. usually directly based on the problem’s statement and definitions of the concepts involved. Where the given array is divided into two equal parts. 12) What is the time complexity of merge sort? n log n. 11) On which paradigm is it based? Merge-sort is based on the divide-and-conquer paradigm. The left part of the array as well as the right part of the array is sorted recursively. 13) What is the space requirement of merge sort? Space requirement: Θ(n) (not in-place). 2 Brute force is a straight forward approach to solving a problem. In – place if it does not use extra memory. 10) Who invented Merge Sort? John Von Neumann in 1945. 8) What is the time complexity of heap sort? Θ( n logn) 9) What is Merge Sort? Merge sort is an O (n log n) comparison-based sorting algorithm.html . Later. MCA | Collections: http://srinivas-rangan. Brute force 16) Define Brute force strategy.blogspot. 15 ) Name the design strategy used in Selection Sort. both the left part and right part are merged into a single sorted array.in/p/mca-study-materials. 2 Selection Sort algorithm requires (n-1) swaps & hence  (n) memory writes.in/p/mca-study-materials. 19) Is Selection Sort stable? Yes.blogspot. 24) What is principle of optimality? The optimal solution to any instance of an optimization problem is composed of optimal solutions to its subinstances. 22) What are the drawbacks of Selection Sort? Inefficient on large lists. Thus it can be very useful if writes are the most expensive operation. 23) When is a problem said to have overlapping sub problems? A problem is said to have overlapping subproblems if it can be broken down into subproblems which are reused multiple times. 25) Can knapsack problem be solved in any other technique? MCA | Collections: http://srinivas-rangan.17) What is the time complexity of Selection Sort algorithm?  (n2) 18) Is Selection Sort Inplace? Yes. It uses internal sorting.html 3 . It requires same number of iterations no matter how well-organized the array is. 21) When is Selection Sort algorithm useful? Selection Sort algorithm is useful for small inputs because it requires (n ) comparisons. 20) Why is the name Selection Sort? Algorithm selects the smallest number in the array and places it in its final position the sorted array. means it would require the entire array to be in main memory. This is closely related to recursion. 35) What is a Connected Graph? MCA | Collections: http://srinivas-rangan. 34) What is a Weighted Graph? 4 A weighted graph is a graph with numbers assigned to its edges.e. These numbers are called weights or costs. etc. Greedy technique. 27) Compare Dynamic programming and Divide and conquer.i. "BABA" and "ABBA" are the strings "AB" and "BA" of length 2.html . "B" and the empty string “”. Can be applied to find factorial. 26) Mention few applications of dynamic programming. Other common substrings are "A". 29) What is the other name for Dijkstra’s Algorithm? Single Source Shortest Path Algorithm. new subproblems may be generated when the method is applied. Dynamic programming differs from the "Divide and Conquer" (D-and-C) method in the fact that the problems solved by D-and-C can have many nonoverlapping subproblems ... Branch and bound etc. Both use recursion.It can be solved using many other techniques such as BruteForce. To find the longest common substrings of the strings "ABAB".in/p/mca-study-materials. Kruskal’s algorithm 33) What is the constraint on Dijkstra’s Algorithm? This algorithm is applicable to graphs with non-negative weights only. fibonacci numbers in which the required value may depend on previously computed values. Prim’s Algorithm.blogspot. 30) Which technique the Dijkstra’s algorithm is based on? Greedy Technique. 28) Who invented Dijkstra’s Algorithm? Edsger Dijkstra invented this algorithm. 31) What is the purpose of Dijkstra’s Algorithm? To find the shortest path from source vertex to all other remaining vertices 32) Name the different algorithms based on Greedy technique. html . 36) What is the time complexity of Dijkstra’s algorithm? For adjacency matrix. a British Scientist. In Dijkstra’s Algorithm. 39) What are the applications of Dijkstra’s Algorithm? It finds its application even in our day to day life while travelling. They are helpful in routing applications. 40) Who was the inventor of the Quicksort? C.HOARE.R. In TSP. given n cities with known distances b/w each pair .blogspot. 41) Which design strategy does Quicksort uses? Divide and Conquer 42) What is Divide and Conquer Technique? 5 (I) Divide the instance of a problem into two or more smaller instances (II) Solve the smaller instances recursively (III) Obtain solution to original instances by combining MCA | Collections: http://srinivas-rangan.in/p/mca-study-materials. It is O(IVI*IVI) For adjacency list with edges stored as min heap. Dijkstra’s algorithm is to find the shortest path from source vertex to all other remaining vertices. find the shortest tour that passes through all the cities exactly once before returning to the starting city. it is O(IEIlogIVI) 37) Differentiate b/w Traveling Salesman Problem(TSP) and Dijkstra’s Algorithm. find the shortest path from source vertex to all other remaining vertices 38) Differentiate b/w Prim’s Algorithm and Dijkstra’s Algorithm? Prim’s algorithm is to find minimum cost spanning tree.A graph is said to be connected if for every pair of its vertices u and v there is a path from u to v.A. 46) When do you say that a Quick sort having best case complexity? When the pivot exactly divides the array into equal half 47) When do you say that Quick sort having worst case complexity? When any one of the subarray is empty 48) How many more comparisons are needed for average case compared to best case? 38% more 49) when do you say that the pivot element is in its final position? When all the elements towards the left of pivot are <= pivot and all the elements towards the right of pivot are >= pivot.H header file.blogspot.in/p/mca-study-materials.html . greedy technique MCA | Collections: http://srinivas-rangan. 6 51) What technique does kruskal’s algorithm follow.these solutions 43) What is the another name for Quicksort? Partition Exchange Sort 44) What are the advantages and disadvantages? Advantage: Fastest among all sorting algorithms Suitable when the input size is very large Disadvantage: Heavily based on recursive sorting technique It takes O (n* log n) time and O (log n) additional space due to Recursion 45)Is Quicksort Stable as well as In place? Not Stable but In place. 50) What is CLK_TCK? macro defines the number of clock ticks per second which is available in the TIME. If there still remains unvisited vertices. the algorithm to be restarted at an arbitrary vertex of another connected component of a graph. Back edge & Cross edge ? Tree edge: whenever a new unvisited vertex is reached for the first time. 54) Which technique is used to solve BFS & DFS problems? Decrease and Conquer 55) What is BFS traversal? It proceeds in a concentric manner by visiting first all the vertices that are adjacent to a starting vertex.52) What is the time complexity.in/p/mca-study-materials.e. With an efficient sorting algorithm. the edge is noted as a cross edge. until all the vertices are in the same connected component as the starting vertex are visited. Back edge: An edge leading to a previously visited vertex other than its immediate predecessor.html 7 . 56) What is DFS traversal? Consider an arbitrary vertex v and mark it as visited on each iteration. Such an edge is called a back edge Cross edge If an edge leading to a previously visited vertex other than its immediate predecessor (i. its parent in the tree). Is encountered. Such an edge is called a tree edge.(no adjacent unvisited vertex is available). This process continues until we reach the starting vertex. proceed to an unvisited vertex w adjacent to v. it is attached as a child to the vertex from which it is being visited. the time efficiency of an kruskal’s algorithm will be in O(|E|log|E|). Joseph Kruskal. 53) Who is the inventor of kruskal’s algorithm. At the dead end the algorithm backs up by one edge and continues the process of visiting unvisited vertices. 58) What are the various applications of BFS & DFS tree traversal technique? MCA | Collections: http://srinivas-rangan. This process continues until dead end is encountered. then all unvisited vertices two edges apart from it and so on . we can explore this new vertex depending upon its adjacent information. 57) What are Tree edge.blogspot. aj-1(j=1. Topological sorting. if the latter vertex does not have cross edge. 8 63) Define squashed order? Any subsets involving aj can be listed only after all the subsets involving a1. we can take advantage of the graph's representation in the form of a BFS forest. We use queue data structure to traverse the graph in DFS traversal.Application of BFS Checking connectivity and checking acyclicity of a graph.…. To check whether the graph is cyclic or not.n-1) MCA | Collections: http://srinivas-rangan.….html . 60) What are the efficiencies of BFS & DFS algorithms for Adjacency matrix and adjacency list representation? Adjacency matrices: Θ(V2) Adjacency linked lists: Θ(V+E) 61) Define set? Set is unordered collection of distinct items.blogspot.in/p/mca-study-materials. For checking cycle presence. then the graph is acyclic. 62) Define power set? The set of all subsets of a set is a power set. To find the spanning tree. 59) Which data structures are used in BFS & DFS tree traversal technique? We use Stack data structure to traverse the graph in DFS traversal. Application of DFS To check whether given graph is connected or not. then it is connected graph otherwise disconnected graph.2. If there is only one root in the BFS forest. Check whether there is only one root in the BFS forest or not. html .64) What are the ways of generating subsets? Decrease by constant Bit string based algorithm Minimal change algorithm 65) Explain time and space trade off strategy. 70) Differentiate between Brute-Force technique and Horspool algorithm for string matching. It is a technique in which the problem’s input is preprocessed in whole or in part and the additional information stored is obtained to solve the problem. In Horspool. if there is a character mismatch then we shift the pattern to the right by 1 position. It is a strategy in which time efficiency can be achieved at the cost of extra memory usage. 68) What is a shift table? It is a table that stores the shift information i.in/p/mca-study-materials. if there is a mismatch then the shift size is obtained from the shift table and the pattern is shifted accordingly. b) In brute-force technique. a) In brute-force. 9 MCA | Collections: http://srinivas-rangan. 71) Differentiate between Horspool and Boyer -Moore algorithms. comparison starts from left where as in Horspool comparison starts from right. 66) Which technique does the Horspool algorithm uses? Input enhancement technique 67) Explain Input enhancement technique. 69) Which is better Brute Force or Horspool algorithm for string matching? Horspool is better as it reduces the number of comparisons.e it stores the distance of each rightmost character in the first “m-1” characters of the pattern from the last character of the pattern and stores the length of the pattern as the shift size if the character is not present in the pattern.blogspot. 72) What is Dynamic Programming? It is a technique for solving problems with overlapping sub problems.computations are not preformed.Horspool algorithm uses only Shift table to obtain the shift information. 10 77) What is a minimum spanning tree ? MCA | Collections: http://srinivas-rangan. 76) What is a spanning tree ? A spanning tree of a weighted connected graph is its connected acyclic(no cycles) subgraph (i. 74) What is the Space & Time complexity of DP algo for Binomial Coefficient C(n. Very precisely re . the solution is retrieved from the table and never recomputed.blogspot. Using the solutions of sub problems.The shift information of this table is known as d1 -Good suffix shift table The shift information from this table is known as d2. 73) What does Dynamic Programming have in common with Divideand-Conquer? Both solve the problems by dividing the problem into sub problems.in/p/mca-study-materials. a tree)that contains all the vertices of a graph. -Bad symbol shift table (same as the shift table used by Horspool).html . Shifting is done by taking max(d1.d2). the solutions for larger instance of the problem can be obtained. If the same instance of sub problem is encountered. Boyer .e. k)? Θ(nk) 75) What is a principle difference between the two techniques? Only one instance of the sub problem is computed & stored.Moore algorithm uses 2 tables. Irrevocable: i.blogspot. Greedy technique. then we take into the account of cost factor for communication links. Locally optimal: i.html . Unseen vertices : vertices which are not adjacent are called unseen.Minimum spanning tree of a connected graph is its spanning tree of smallest weight.e. 79) State greedy technique for solving problem. What are fringes and unseen vertices? Fringes: vertices which are connected are called fringes. untill the complete solution is reached. it cannot be changed on subsequent steps of the algorithm. to pass the data from one node to another node we can find the shortest distance easily by this algorithm. 80) Name some of the application greedy technique They are helpful in routing applications: In the case of network where large number of computers are connected. 78) Prim’s algorithm is based on which technique. once made. it has to be the best local choice among all feasible choices available on that step.e. 11 81) Does Prim’s Algorithm always yield a minimum spanning tree ? Yes MCA | Collections: http://srinivas-rangan. On each step the choice must be made as Feasible: i. Building a road network that joins n cities with minimum cost. Communication Networks: Suppose there are 5 different cities and we want to establish computer connectivity among them. A greedy approach constructs a problem through a sequence of steps each expanding a partially constructed solution obtained so far. it has to satisfy the problem’s constraints.e.in/p/mca-study-materials. To find the all pair shortest path.blogspot. 85) What is shortest path? . Root represents an initial state before the search for solution begins.in/p/mca-study-materials.In which the element dij indicates the length of the path from ith vertex to the jth vertex.It is the path which is having shortest length among all possible paths. 83) What is the time efficiency of floyd’s algorithm? . 91) hard problems can be solved by which method? Back tracking and branch and bound techniques used for large instance of combinatorial problems. 86) warshall’s algorithm is optimization problem or non-optimization problem ? Non-optimization problem 87) For what purpose we use Warshall’s algorithm? Warshall’s algorithm for computing the transitive closure of a directed graph 88) Warshall’s algorithm depends on which property? Transitive property 89) what is the time complexity of Warshall’s algorithm? Time complexity of warshall’s algorithm is (n3) 90) what is hard problem? Optimization problems which are having complexity of exponential or factorial.82) What is the purose of Floyd’s algoreithm? .html . 84) What is distance matrix? . MCA | Collections: http://srinivas-rangan.It is same as warshall’s algorithm that is θ(n3). 12 92) what is state space tree? Constructing a tree of choices being made and processing is known as state-spacetree. 13 MCA | Collections: http://srinivas-rangan. It uses DFS search technique.93) what are promising and non-promising state-space-tree? Node which may leads to solution is called promising.html . 94) Differentiate between backtracking and Branch and Bound. Backtracking is applicable to non-optimization problems most of the times and sometimes optimization problems. 95) In Backtracking what does the leaf node indicates? It indicates either a non promising dead ends or solutions to the problem. Node which doesn’t leads to solution is called non-promising.in/p/mca-study-materials. Branch and Bound uses Best first search technique and is applicable to optimization problems.blogspot.
Copyright © 2021 DOKUMEN.SITE Inc.