AMCAT Placement Paper - 2

1)      Ravi and rupali are asked to write  a program to sum of the row of a 2X2 matrices stored in  the array A.
Ravi writes the following code (code A):
For n=0 to 1
sumRow1[n]=a[n][1]+a[n][2]
end

rupali writes the following code (code B):
sumRow1[0]=A[0][1]+A[0][2]
sumRow1[1]=A[1][1]+A[1][2]
comment upon these codes(assume no loop- unrolling done by compiler)
a)      Code A will execute faster than code B
b)      Code B will execute faster than code A
c)       Code A is logically incorrect
d)      Code B is logically incorrect
2)      As part of maintenance work, you are entrusted with the work of rearranging the library books in a shelf in proper order. At the end of each day. The ideal choice will be
a)      Bubble sort
b)      Insertion sort
c)       Selection sort
d)      Heap sort
3)      Shahaana has a 10,000 line code. She is trying to debug it. She knows there is a logical error In the first 25 lines of the code. Which of the following option will be an efficient way of debugging?
a)      Compile the whole code and step into it line by line
b)      Use an interpreter on the first 25 lines
c)       Compile the whole code and run it
d)      None of these
4)      Shrishti writes a program to find an element in an array A[5} with the following elements in order 8,30,40,45,70. She  runs the program to find a number x. x is found in the first iteration of binary search. What is the value  x?
a)      40
b)      8
c)       70
d)      30
e)      8
5)      Consider the following pseudo-cod
Class brush
{
Private:
Integer size,colorcode;
Function getdata(){…..}//statment1
Public:
Integer name //statement-2
Function putdata(){….}
}
Function main
{
Brush b1,b2
Print b1.name//statement 3
B2.getdata()//statement 4
}
Choose the correct answer. A pseudo-code which is similar to that of C++ and self-explanatory. An accessible member function or data member for an object are accessed by the statement
Objectname.functionname or objectname.datamembername respectively.
a)      Statment1
b)      Statment2
c)       Statment3
d)      Statment4
6)      A full binary tree with n leaves contains
a)      2n+1 nodes
b)      Log2n nodes
c)       2n-1 nodes
d)      2n nodes
7)      Intger n,I,j
Input n
For i=0 to n increment 1
Print end-of line//takes the cursor to the next line
For j=0 to I increment 1
{
If(i-j equals 1)
Print “1”
Else
Print “10”
}
}
Madumitha writes the given pseudo code to pring pattern on screen
What is the pattern that this code will print on screen if the  value of n is 4


a)      1
101
10101
b)      1
101
10101
101010
c)
d)
8)      Which of the following data structures may give overflow error, even though the current number of elements in it is less than its size?
a)      Queue implemented in a linear array
b)      Queue implemented in a circularly connected array
c)       Stack implemented in a linear array
d)      None of these
9)      Suppose that graph is represented as adjacency matrix and a BFS algoritham is modified to handle such input graphs which of the following options refers to the running time of such an algoritham given that the number of vertices in the graph is v and number of edges is E?
a)      O(V*V)
b)      O(V*V+E)
c)       O(E*E+V)
d)      O(E*E)
10)    Which of the following options describes a tree?
a)      An unconnected graph
b)      A connected graph
c)       A connected acyclic graph
d)      A complete graph
11)   What is the term given to the feature of a programming language that is designed to handle the run time errors of a program?
a)      Exception handling
b)      Error handling
c)       Debugging
d)      Dynamic error handling
12)    Function operation (int a, int b)
{
If(a<b)
Return operation (b,a)
Else
Retrun a
}
a)      Retruns the max of (a,b)
b)      Returns the min of (a,b)
c)       Loops forever
d)      Always returns the second parameter
13)   If the depth first search of a directed graph G yields no back edges, then what can be said about the graph G?
a)      G is acyclic
b)      G is cyclic
c)       G is bipartite
d)      G is strongly connected
14)   A graph G with n node is bipartite if it contains
a)      N edges
b)      A cycle of odd  length
c)       No cycle of odd length
d)      N^2 edges
15)   Geetika writes a piece of code . where a set of eight lines occur around 10 times in different parts of the program (code A). She passes on the code Deva. Deva puts the set of eight lines in a function definition and calls them at the 10 points in the program(code B) which code will run faster using an interpreter?
a)      Code A
b)      Cod e B
c)       Code A and Code B will run with the same speed
d)      None of these
16)    Which of the following data types not belong to the category of abstract data types?
a)      Hash table
b)      Set
c)       Object
d)      Stack
17)   A complete binary tree with the property that the value at each node is atleast as large as the values at its children is known as
a)      Binary search tree
b)      Avl tree
c)       Completely balanced tree
d)      Heap
18)   Which of the following sorting algortithms yield approximately the sma worst-case and average-case running time behaviour in O(n logn)?
a)      Bubble sort and selection sort
b)      Heap sort and merge sort
c)       Quick sort and radix sort
d)      Tree sort and median-of-3 quick sort
19)   Which of these is not a data type?
a)      Intger
b)      Character
c)       Boolean
d)      Array
20)    In BFS, WHICH of the followooing options is true?
a)      Beginning from a node , first all its adjacent nodes are traversed.
b)      Beginning from a node, each adjacent node is fully explored before traversing the next adjacent node
c)       Beginning from a node, nodes are traversed in a cyclical order
d)      None of these

No comments:

Post a Comment