81. In what way the Symmetry Sparse Matrix can be stored efficiently?
Answer:
Explanation:Since Symmetry Sparse Matrix arises as the adjacency matrix of the undirected graph. Hence it can be stored efficiently as an adjacency list.
Workspace
Societe Generale
82. If column-major order is used, how is the following matrix stored in memory?
Answer:
Explanation:It starts with the first element and continues in the same column until the end of column is reached and then proceeds with the next column. Fortran follows column-major order.
Workspace
Societe Generale
83. If the array is already sorted, then the running time for merge sort is: ?
Answer: O(n*log n)
Explanation:Here is no explanation for this answer
Workspace
Societe Generale
84. quicksort algorithm is used to sort an array of N elements. If all the N values w
complexity of quicksort that uses first element as the pivot. ?
Answer: O(N*N)
Explanation:Here is no explanation for this answer
Workspace
Societe Generale
85. The complexity of merge sort algorithm is
Answer: O(n log n)
Explanation:Here is no explanation for this answer
Workspace
Societe Generale
86. What is the time taken to delete a minimum element in a leftist heap?
Answer:
Explanation:The time taken to delete a minimum element in a leftist heap is mathematically found to be O(log N).
Workspace
Societe Generale
87. The amortized time efficiency for performing deletion of a minimum element is?
Answer:
Explanation:The amortized time efficiency for performing deletion of a minimum element is mathematically found to be O(log N).
Workspace
Societe Generale
88. Consider the C function given below. Assume the array listA contains (n>0) elements, sorted in ascending order.
int Process array (int * list A, int x, int n)
{
int i, j, k;
i =0;j=n-1;
do {
k = (i+j)/2;
if (x<=list A[k])
j=k-1;
if (list A[k] <=x)
i =k+1;
} while (i <=j);
if (list A[k] == x)
return (k);
else
return -1;
}
Answer: It is an implementation of binary search.
Explanation:Here is no explanation for this answer
Workspace
Nagarro Societe Generale TCS NQT
89. In worst case Quick Sort has order
Answer: O[n^2)/2]
Explanation:Here is no explanation for this answer
Workspace
Societe Generale
90. Select the code snippet which returns the top of the stack.
I. public int top()
{
if(q1.size()>0)
{
return q1.poll();
}
else if(q2.size()>0)
{
return q2.poll();
}
return 0;
}
II. public int top()
{
if(q1.size()==0)
{
return q1.peek();
}
else if(q2.size()==0)
{
return q2.peek();
}
return 0;
}
III. public int top()
{
if(q1.size()>0)
{
return q1.peek();
}
else if(q2.size()>0)
{
return q2.peek();
}
return 0;
}
IV. public int top()
{
if(q1.size()>0)
{
return q2.peek();
}
else if(q2.size()>0)
{
return q1.peek();
}
return 0;
}
Answer:
Explanation:Assuming its a push costly implementation, the top of the stack will be in the front end of the queue, note that peek() just returns the front element, while poll() removes the front element from the queue.
Workspace
Societe Generale