Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Section Summary
No. of Questions: 77
Duration: 10 min
Additional Instructions:
None
12
Q2. A telephone exchange offers a directory service. A person calls a number, and
speaks the name of the party to the operator. The operator then types the name
she heard into the computer. Here, it is converted into a “phoneme”, where two
names that sound the same, but spelt differently (Gupta and Gooptha) are
identical. This phoneme is used to access a disk data structure with a relatively
slow disk, and no cache in the disk.. The telephone exchange is in a large city with
over a crore entries. The disk will be accessed until all the names with the same
phoneme are retrieved, and the additional details (address, locality) used to identify
the correct person an get the appropriate phone number. What is the best data
structure for storing the phonemes and associated data in the disk?
https://myslate.sixphrase.com/ 1/34
8/31/2018 Six Phrase - mySlate
Balanced Tree
Hash Structure
Q3. The Tower of Hanoi game consists of three pegs (towers) – A,B,C with n disks
placed one over the other on peg A such that the disks are arranged in decreasing
diameter from bottom to top. The objective of the game is to move the stack of
disks from peg A to peg C following these simple rules: 1) Only one disk can be
moved at a time. 2) Each move consists of taking the upper disk from one of the
stacks and placing it on top of another stack or on an empty rod. 3) For temporary
storage, peg B may be used 4) No disk may be placed on top of a smaller disk.
Eesha tried to manually carryout re-ordering of 14 disks using the above rules. She
rst worked out the strategy to make the minimum number of moves, and then
carried this out. She made 1 move per second and spent exactly 1 hour per day in
arranging disks. She started her rst move on a Monday. On which day did she
nish the game ?
Wedneday
Friday
Monday
Q4. Consider the usual algorithm for determining whether a sequence of parentheses
is balanced. The maximum number of parentheses that appear on the stack AT
ANY ONE TIME when the algorithm analyzes: (()(())(())) are:
https://myslate.sixphrase.com/ 2/34
8/31/2018 Six Phrase - mySlate
3
Q5. A sort algorithm, when sorting in ascending order will obviously put items with
lower keys before items with higher keys. How it treats items with equal keys
de nes an important property. A sort algorithm is said to be stable if two items
with equal keys will be guaranteed to come out n the output sequence in the same
order as in the input. An algorithm is said to be of time complexity O(f(n)), where
f(n) is a function of n, if, for large values of n, the number of operations to execute
it is proportional to f(n). A bubble sort is a sort algorithm that keeps exchanging
adjacent items if they are in the wrong order.Consider the following statements: A
The bubble sort is stable. B The bubble sort has time complexity O(n log n), in the
worst case (input is sorted in the reverse order)
A is true, B is false
A is false, B is true
A is true, B is true
Compilation error
https://myslate.sixphrase.com/ 3/34
8/31/2018 Six Phrase - mySlate
Q7. Given an array arr = {5,6,77,88,99} and key = 88; How many iterations are done until
the element is found?
2
Q8. If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a
time, in what order will they be removed?
ABCD
DCBA
DCAB
ABDC
Q9. Consider the usual algorithm for determining whether a sequence of parentheses
is balanced. Suppose that you run the algorithm on a sequence that contains 2 left
parentheses and 3 right parentheses (in some order). The maximum number of
parentheses that appear on the stack AT ANY ONE TIME during the computation?
2
https://myslate.sixphrase.com/ 4/34
8/31/2018 Six Phrase - mySlate
4 or more
O(nlogn)
O(logn)
O(n)
O(n2)
0, 0.100000
0, 0.999999
Q12. Given an array arr = {45,77,89,90,94,99,100} and key = 100; What are the mid
values(corresponding array elements) generated in the rst and second iterations?
https://myslate.sixphrase.com/ 5/34
8/31/2018 Six Phrase - mySlate
90 and 99
90 and 100
89 and 94
94 and 99
Q13. A normal queue, if implemented using an array of size MAX_SIZE, gets full when
Rear = MAX_SIZE – 1
Front = rear + 1
Rear = front
Q15. The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements.
How many iterations will be done to sort the array with improvised version?
https://myslate.sixphrase.com/ 6/34
8/31/2018 Six Phrase - mySlate
2
Q16. Which of the following type-casting have chances for wrap around?
int to char
int to oat
char to short
char to int
https://myslate.sixphrase.com/ 7/34
8/31/2018 Six Phrase - mySlate
Q18. Convert the following in x expressions into its equivalent post x expressions (A +
B ⋀D)/(E – F)+G
(A B D +⋀ E F – / G +)
(A B D ⋀ + E F/- G +)
(A B D ⋀ + E F – / G +)
Q19. Here is an in x expression: 4 + 3*(6*3-12). Suppose that we are using the usual
stack algorithm to convert the expression from in x to post x notation. The
maximum number of symbols that will appear on the stack AT ONE TIME during
the conversion of this expression?
4
Q20. What is the advantage of bubble sort over other sorting techniques?
It is faster
https://myslate.sixphrase.com/ 8/34
8/31/2018 Six Phrase - mySlate
O(nlogn)
O(logn)
O(n)
O(n2)
*AB/CD+
AB*CD/+
A*BC+/D
ABCD+/*
Q23. Assume that the operators +,-, X are left associative and ^ is right associative. The
order of precedence (from highest to lowest) is ^, X, +, -. The post x expression for
the in x expression a + b X c – d ^ e ^ f is
abc X+ def ^^ –
abc X+ de^f^ –
ab+c Xd – e ^f^
-+aXbc^ ^def
https://myslate.sixphrase.com/ 9/34
8/31/2018 Six Phrase - mySlate
Preorder traversal
Inorder traversal
Postorder traversal
Widening conversions
Narrowing conversions
Q26. What will be the output of the program (myprog.c) given below if it is executed
from the command line?
/* myprog.c */
#include<stdio.h>
https://myslate.sixphrase.com/ 10/34
8/31/2018 Six Phrase - mySlate
myprog one
o
two
Q27. What is the time complexity of inserting a node in a doubly linked list?
O(nlogn)
O(logn)
O(n)
O(1)
https://myslate.sixphrase.com/ 11/34
8/31/2018 Six Phrase - mySlate
Q30. Suppose we have numbers between 1 and 1000 in a binary search tree and want to
search for the number 363. Which of the following sequence could not be the
sequence of the node examined?
Q31. What does the following function check for? (all necessary headers to be included
and function is called from main)
#de ne MAX 10
typedef struct stack
https://myslate.sixphrase.com/ 12/34
8/31/2018 Six Phrase - mySlate
{
int top;
int item[MAX];
}stack;
int function(stack *s)
{
if(s->top == -1)
return 1;
else return 0;
}
full stack
invalid index
empty stack
in nite stack
Q32. The maximum combined length of the command-line arguments including the
spaces between adjacent arguments is
128 characters
256 characters
67 characters
Q33. What is the time complexity of inserting at the end in dynamic arrays?
O(1)
O(n)
https://myslate.sixphrase.com/ 13/34
8/31/2018 Six Phrase - mySlate
O(logn)
It is an array of strings
None of above
Q35. According to ANSI speci cations which is the correct way of declaring main when
it receives command-line arguments?
int main()
{
int argc; char *argv;
}
None of above
if(temp.getData() == data)
{
return var;
}
var = var+1;
temp = temp.getNext();
}
return Integer.MIN_VALUE;
}
int main()
{
int x, y, m, n;
scanf ("%d %d", &x, &y);
/* x > 0 and y > 0 */
m = x; n = y;
while (m != n)
{
if(m>n)
m = m - n;
else
n = n - m;
}
printf("%d", n);
}
https://myslate.sixphrase.com/ 15/34
8/31/2018 Six Phrase - mySlate
Q38. In full binary search tree every internal node has exactly two children. If there are
100 leaf nodes in the tree, how many internal nodes are there in the tree?
99
25
49
101
push(20);
push(4);
top();
pop();
pop();
pop();
push(5);
top();
20
stack under ow
5
https://myslate.sixphrase.com/ 16/34
8/31/2018 Six Phrase - mySlate
Q40. What is the time complexity to count the number of elements in the linked list?
O(1)
O(n)
O(logn)
Q41. What will be the output of the program (myprog.c) given below if it is executed
from the command line?
/* myprog.c */
#include<stdio.h>
#include<stdlib.h>
myprog
one
two
three
Q42. Which of the following statements are FALSE about the below code?
int main(int ac, char *av[])
{
}
https://myslate.sixphrase.com/ 17/34
8/31/2018 Six Phrase - mySlate
head-0-1-2-3-4-5-6-tail
head-1-2-3-4-5-6-tail
head-6-1-2-3-4-5-0-tail
head-0-1-2-3-4-5-tail
(i) The value stored in the CPU register can always be accessed faster than that
stored in memory.
(ii) A register storage class variable will always be stored in a CPU register.
Only I is correct
https://myslate.sixphrase.com/ 18/34
8/31/2018 Six Phrase - mySlate
Only II is correct
Q45. A binary search tree is generated by inserting in order the following integers:
50, 15, 62, 5, 20, 58, 91, 3, 8, 37, 60, 24
The number of the node in the left sub-tree and right sub-tree of the root,
respectively, is
(4, 7)
(7, 4)
(8, 3)
(3, 8)
Dequeue
enqueue
https://myslate.sixphrase.com/ 19/34
8/31/2018 Six Phrase - mySlate
O(1)
O(n)
O(logn)
Q48. In the worst case, the number of comparisons needed to search a singly linked list
of length n for a given element is
log 2 n
n/2
log 2 n – 1
n
Q49. What is the time complexity of pop() operation when the stack is implemented
using an array?
O(1)
O(n)
https://myslate.sixphrase.com/ 20/34
8/31/2018 Six Phrase - mySlate
O(logn)
O(nlogn)
Q50. What will be the output of the program (sample.c) given below if it is executed from
the command line (Turbo C in DOS)?
cmd> sample 1 2 3
/* sample.c */
#include<stdio.h>
Error
sample 6
Garbage value
Q51. What will be the output of the program (sample.c) given below if it is executed from
the command line (turbo c under DOS)?
cmd> sample Good Morning
/* sample.c */
#include<stdio.h>
3 Good
https://myslate.sixphrase.com/ 21/34
8/31/2018 Six Phrase - mySlate
2 Good
Good Morning
3 Morning
123
1234
234
Q53. What will be the output of the program (sample.c) given below if it is executed from
the command line?
cmd> sample "*.c"
/* sample.c */
#include<stdio.h>
*.c
"*.c"
sample *.c
Q54. What will be the output of the program (sample.c) given below if it is executed from
the command line?
cmd> sample friday tuesday sunday
/* sample.c */
#include<stdio.h>
f
sample
friday
Q55. What will be the output of the program if it is executed like below?
cmd> sample
/* sample.c */
#include<stdio.h>
https://myslate.sixphrase.com/ 23/34
8/31/2018 Six Phrase - mySlate
sample
samp
no output
r
Q57. What will be the output of the program (sample.c) given below if it is executed from
the command line?
cmd> sample one two three
/* sample.c */
#include<stdio.h>
https://myslate.sixphrase.com/ 24/34
8/31/2018 Six Phrase - mySlate
owt
eno
eerht
Q58. What will be the output of the program (sample.c) given below if it is executed from
the command line?
cmd> sample 1 2 3
cmd> sample 2 2 3
cmd> sample 3 2 3
/* sample.c */
#include<stdio.h>
sample 3 2 3
sample 1 2 3
sample
Error
Q59. Suppose you are provided with the following function declaration in the C
programming language.
https://myslate.sixphrase.com/ 26/34
8/31/2018 Six Phrase - mySlate
head-6-1-2-3-4-5-tail
head-6-1-2-3-4-tail
head-1-2-3-4-5-6-tail
head-1-2-3-4-5-tail
https://myslate.sixphrase.com/ 27/34
8/31/2018 Six Phrase - mySlate
}
var = var+1;
temp = temp.getNext();
}
return Integer.MIN_VALUE;
}
Q63. The following C function takes a single-linked list of integers as a parameter and
rearranges the elements of the list.
The function is called with the list containing the integers 1, 2, 3, 4, 5, 6, 7 in the
given order. What will be the contents of the list after the function completes
execution?
struct node
{
int value;
struct node *next;
};
void rearrange(struct node *list)
{
struct node *p, * q;
int temp;
if ((!list) || !list->next)
return;
p = list;
q = list->next;
while(q)
{
temp = p->value;
p->value = q->value;
q->value = temp;
p = q->next;
q = p?p->next:0;
}
}
https://myslate.sixphrase.com/ 28/34
8/31/2018 Six Phrase - mySlate
1, 2, 3, 4, 5, 6, 7
2, 1, 4, 3, 6, 5, 7
1, 3, 2, 5, 4, 7, 6
2, 3, 4, 5, 6, 7, 1
Q64. You are given pointers to rst and last nodes of a singly linked list, which of the
following operations are dependent on the length of the linked list?
Q65. What does the following function do for a given Linked List with rst node as head?
https://myslate.sixphrase.com/ 29/34
8/31/2018 Six Phrase - mySlate
struct item
{
int data;
struct item * next;
};
int f(struct item *p)
{
return (
(p == NULL) ||
(p->next == NULL) ||
(( P->data <= p->next->data) && f(p->next))
);
}
https://myslate.sixphrase.com/ 30/34
8/31/2018 Six Phrase - mySlate
Q68. In a singly linked list, each node has a pointer to the next node in the list. The last
node points to nothing.Eesha wrote an iterative function that takes the rst node of
a singly linked list as argument, reverses the list, and returns the rst node from the
resulting list.However, she did not get the correct result. The pseudo code for this
function is given below. In which line number has she made a mistake? _________
int data;
NODE *ptr;
Q71. Four matrices M1, M2, M3 and M4 of dimensions pxq, qxr, rxs and sxt respectively
can be multiplied is several ways with different number of total scalar
multiplications. For example, when multiplied as ((M1 X M2) X (M3 X M4)), the
total number of multiplications is pqr + rst + prt. When multiplied as (((M1 X M2) X
M3) X M4), the total number of scalar multiplications is pqr + prs + pst.If p = 10, q =
100, r = 20, s = 5 and t = 80, then the number of scalar multiplications needed is:
_________
_________
Q73. Consider two strings A = "qpqrr" and B = "pqprqrp". Let x be the length of the
longest common subsequence (not necessarily contiguous) between A and B and
let y be the number of such longest common subsequences between A and B.
Then x + 10y = _________ .
Q74. What is the output of following function for start pointing to rst node of following
linked list?
_________
https://myslate.sixphrase.com/ 32/34
8/31/2018 Six Phrase - mySlate
Q75. Let A1, A2, A3, and A4 be four matrices of dimensions 10 x 5, 5 x 20, 20 x 10, and
10 x 5, respectively. The minimum number of scalar multiplications required to nd
the product A1A2A3A4 using the basic matrix multiplication method is _________
Q76. The following C function takes a simply-linked list as input argument.It modi es the
list by moving the last element to the front of the list and returns the modi ed list.
Some part of the code is left blank. _________ .
Q77. #include<stdio.h>
int bo(int n)
if(n<=1)
return n;
int main()
{
int r = bo(50000);
printf("%d",r);
https://myslate.sixphrase.com/ 33/34
8/31/2018 Six Phrase - mySlate
return 0;
}
_________
https://myslate.sixphrase.com/ 34/34