Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

1) What does the following fragment of C-program print?

char c[] = "GATE2011";


char *p =c;
printf("%s", p + p[3] - p[1]) ;
(A) GATE2011
(B) E2011
(C) 2011
(D) 011
Answer: (C)
2. struct node
{
int i;
float j;
};
struct node *s[10];
The above C declaration define ‘s’ to be (GATE CS 2000)
(A) An array, each element of which is a pointer to a structure of type node
(B) A structure of 2 fields, each field being a pointer to an array of 10 elements
(C) A structure of 3 fields: an integer, a float, and an array of 10 elements
(D) An array, each element of which is a structure of type node.
Answer: (A)
3. The maximum number of binary trees that can be formed with three unlabeled nodes is:
(A) 1
(B) 5
(C) 4
(D) 3
Answer: (B)
Note that nodes are unlabeled. If the nodes are labeled, we get more number of trees.
We can find the number of binary tree by Catalan number number:
Here n = 3
Number of binary tree = (2nCn)/ n+1
= (2*3C3)/ 4+1
= 5.
So, option (B) is correct.
4. In a Circular linked list, insertion of a record involves the modification of____
(A) 1 Pointer
(B) 2 Pointer
(C) 3 Pointer
(D) None of the above
Answer
(B) 2 Pointer
5. The following sequence of operations is performed on a stack:
PUSH (10), PUSH (20), POP, PUSH (10), PUSH (20), POP, POP, POP, PUSH (20), POP
The sequence of values popped out is
a. 20,10,20,10,20
b. 20,20,10,10,20
c. 10,20,20,10,20
d. 20,20,10,20,10
Let us try something different when you read the word pop then delete the last pushed
element and print it. Now , delete the push word which we have already executed. Now, go
on from left to right and do the same.
So, output will be 20,20,10,10,20.
Correct Answer: B
6. The maximum number of nodes in a binary tree of depth k is 2k−1, k≥1.
7. Which of the following sorting algorithms can be used to sort a random linked list with
minimum time complexity?
(A) Insertion Sort
(B) Quick Sort
(C) Heap Sort
(D) Merge Sort
Answer: (D)
Explanation: Both Merge sort and Insertion sort can be used for linked lists.
8. Pumping lemma for regular language is generally used for proving:
(A) whether two given regular expressions are equivalent
(B) a given grammar is ambiguous
(C) a given grammar is regular
(D) a given grammar is not regular
Answer: (D)
Explanation: Pumping lemma is used to prove a language is regular or not.
For more information on pumping lemma Refer:Pumping_lemma
So, option (D) is correct.
9. A pushdown automata behave like a Turing machine when the number of auxiliary memory
is:
(A) 0
(B) 1
(C) 1 or more
(D) 2 or more
Answer: (D)
Explanation: A pushdown automata behaves like a Turing machine when the number of auxiliary
memory is 2 or more.
PDA with 2 or more auxiliary memory have same expressive power.
Generally PDA has one auxiliary memory.
So, option (D) is correct.
10. If L and L' are recursively enumerable, then L is
a. regular
b. context-free
c. context-sensitive
d. recursive
Answer: recursive
11. Consider the function f(x)=sin(x) in the interval x=[π4,7π4]. The number and location(s)
of the local minima of this function are
a. One, at π2
b. One, at 3π2
c. Two, at π2 and 3π2
d. Two, at π4 and 3π2
Answer is (d)
f′(s)=cosx=0 gives root π2 and 3π2 which lie between the given domain in question [π4,7π4]
f′′(x)=−sinx at π2 gives −1<0 which means it is local maxima and at 3π2 it gives 1>0 which is
local minima.
Since, at π2 it is local maxima so, before it, graph is strictly increasing, so π4 is also local
minima.
So, there are two local minima π4 and 3π2.
12. What is the value of limn→∞(1−1/n)2n ?
a. 0
b. e−2
c. e−1/2
d. 1
Ans: b
it takes 1 to power infinity form
limx→∞f(x)g(x)
=elimx→∞(f(x)−1)g(x)
where, (f(x)−1)∗g(x)=−1n∗2n=−2.
ie -2 constant.
so we get final ans is =e−2.
Correct Answer: B
13. Anarkali digitally signs a message and sends it to Salim. Verification of the signature by
Salim requires
(A) Anarkali’s public key.
(B) Salim’s public key.
(C) Salim’s private key.
(D) Anarkali’s private key.
Answer: (A)
Explanation: Sender uses its private key to digitally sign a document. Receiver uses public key of
sender to verify. So option A is correct.
14. Which of the following protocols is used by email server to maintain a central repository
that can be accessed from any machine?
(A) POP3
(B) IMAP
(C) SMTP
(D) DMSP
Answer: (B)
Explanation:

POP3 is post office protocol Version 3.POP is a protocol which listens on port 110 and is
responsible for accessing the mail service on a client machine. POP3 works in two modes such
as Delete Mode and Keep Mode.
IMAP is Internet Messaged Access Protocol which is used by email server to maintain a central
repository that can be accessed from any machine.
SMTP is simple mail transfer protocol.
DMSP is distributed mail service protocol.
15. In 16-bit 2’s complement representation, the decimal number −28 is:
(A) 1111 1111 0001 1100
(B) 0000 0000 1110 0100
(C) 1111 1111 1110 0100
(D) 1000 0000 1110 0100
Answer: (C)
Explanation: 2’s complement of a decimal number:
+28 ⇒ 0000 0000 0001 1100
–28 ⇒ 1111 1111 1110 0100 (2’s complement form)
Option (C) is correct.
16. Which one of the following is NOT a valid identity?
(A) (x ⊕ y) ⊕ z = x ⊕ (y ⊕ z)
(B) (x + y) ⊕ z = x ⊕ (y + z)
(C) x ⊕ y = x + y, if xy = 0
(D) x ⊕ y = (xy + x′y′)′
Answer: (B)
Explanation: According to Exor (⊕) operation,
X Y X⊕Y
0 0 0
0 1 1
1 0 1
1 1 0
Therefore, option (D),
x⊕y
= (x'y + xy′)
= (x'+y').(x+y)
= (x⊙y)'
= (xy + x′y′)′
It also clearly shows that, if atleast one of x and y is 0, then it works as (x+y).
x⊕y = x + y, if xy = 0
You can notice that it works as (x+y) except last row in given Truth table, because only last row
does not satisfy (x.y)=0. So, option (C) is also correct.
Exor (⊕) operation also satisfies associative law, i.e.,
(x ⊕ y) ⊕ z = x ⊕ (y ⊕ z)
So, option (A) is also correct.
But, option (B) is not correct because,
(x+y)⊕z
= (x+y)'.z + (x+y).z'
= (x'y').z + xz' + yz'
And,
x⊕(y+z)
= x'.(y+z) + x.(y+z)'
= x'y + x'z + x.y'z'
Therefore,
(x+y)⊕z ≠ x⊕(y+z)
17. Given f(w, x, y, z) = Σm(0,1,2,3,7,8,10) + Σd(5,6,11,15), where d represents the don’t-care
condition in Karnaugh maps. Which of the following is a minimum product-of-sums(POS)
form of f(w,x,y,z)?
(A) f = (w’ + z’ )( x’ + z )
(B) f = (w’ + z ) ( x + z )
(C) f = ( w + z ) ( x ‘ + z )
(D) f = ( w + z’ ) ( x’ + z )
Answer: (A)
Explanation:
18. An interface that provides I/O transfer of data directly to and form the memory unit and
peripheral is termed as________
A. DDA
B. Serial interface
C. BR
D. Direct Memory Access (DMA)
Answer
C. Direct Memory Access (DMA)
19. In a non-vectored interrupt, the address of interrupt service routine is ?
A. Obtained from interrupt address table.
B. Supplied by the interrupting I/O device.
C. Obtained through Vector address generator device.
D. Assigned to a fixed memory location.
Explanation:-
Answer : D
20. The cache memory of 1K words uses direct mapping with a block size of 4 words. How
many blocks can the cache accommodate?
a. 256 words
b. 512 words
c. 1024 words
d. 128 words
Answer: 256 words
21. Arithmetic shift left operation. Produces the same result as obtained with logical shift left
operation. Is not applicable for signed 2's complement representation. Needs additional
hardware to preserve the sign bit.
22. Linear search: best case O(1), Worst Case O(n)
Insert into BST: Avr. Run time O(log n)
Run time for Quick Sort if largest value in the list is always pivot: O(n)
23. This layer is an addition to OSI model when compared with TCP IP model
a) Application layer
b) Presentation layer
c) Session layer
d) Both Session and Presentation layer
View Answer
Answer: d
Explanation: The only difference between OSI model and TCP/IP model is that in OSI model two
layers namely Presentation and Session layer have been added.
24. The network layer concerns with
a. bits
b. frames
c. packets
d. none of the mentioned
Answer: packets
25. In the worst case, the number of comparisons needed to search a singly linked list of
length n for a given element is
(A) log 2 n
(B) n/2
(C) log 2 n – 1
(D) n
Answer: (D)
Explanation: In the worst case, the element to be searched has to be compared with all elements
of linked list.
26. Which of the technique can be used to prove that a language is non regular?
a) Ardens theorem
b) Pumping Lemma
c) Ogden’s Lemma
d) None of the mentioned
View Answer
Answer: b
Explanation: We use the powerful technique called Pumping Lemma, for showing certain
languages not to be regular. We use Ardens theorem to find out a regular expression out of a
finite automaton.
27. The data structure required for Breadth First Traversal on a graph is?
a) Stack
b) Array
c) Queue
d) Tree
View Answer / Hide Answer
ANSWER: c) Queue

2) Consider the following recursive C function that takes two arguments


unsigned int foo(unsigned int n, unsigned int r) {
if (n > 0) return (n%r + foo (n/r, r ));
else return 0;
}
What is the return value of the function foo when it is called as foo(513, 2)?
(A) 9
(B) 8
(C) 5
(D) 2
Answer: (D)
3) What is the return value of the function foo when it is called as foo(345, 10) ?
(A) 345
(B) 12
(C) 5
(D) 3
Answer: (B)
The call foo(345, 10) returns sum of decimal digits (because r is 10) in the number n. Sum of
digits for 345 is 3 + 4 + 5 = 12.
6. In a complete k-ary tree, every internal node has exactly k children or no child. The number of
leaves in such a tree with n internal nodes is:

(A) nk

(B) (n – 1) k+ 1

(C) n( k – 1) + 1

(D) n(k – 1)

Answer: (C)

Explanation: For an k-ary tree where each node has k children or no children, following relation
holds

L = (k-1)*n + 1

Where L is the number of leaf nodes and n is the number of internal nodes.

7. The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3 children is:
(A) n/2
(B) (n-1)/3
(C) (n-1)/2
(D) (2n+1)/3
Answer: (D)
Explanation: Let L be the number of leaf nodes and I be the number of internal nodes, then
following relation holds for above given tree (For details, please see question 3 of this post)
L = (3-1)I + 1 = 2I + 1
Total number of nodes(n) is sum of leaf nodes and internal nodes

You might also like