DS CCW
DS CCW
a. a+b*c
b. ab+c-
c. abc+*d-e+
d. a*+b(c-d)
a. FIFO principle
b. LIFO principle
c. Hierarchical structure
d. Disordered array
13. The time complexity for deleting a node in a linked list is:
a. O(1)
b. O(n)
c. O(nlogn)
d. O(logn)
14. How many of possible ordered trees with 3 nodes A, B, C will be formed ?
(a) 16 (b) 12
(c) 6 (d) 10
If the depth is 1, the root maybe one of the 3 nodes A, B, C. Corresponding to a root,
say A, 2 trees are possible as this.
15. A binary tree in which every non-leaf node has non-empty left and right
subtrees is called a strictly binary tree. Such a tree with 10 leaves.
(a) maximum 19 nodes
(b) has exactly 19 nodes
(c) has exactly 17 nodes
(d) cannot have more than 17 nodes
Solution: Option (b)
Explanation:
The configuration of 10 leaves can only be of the following way:
Any tree with n-leaves, for strict binary tree has (2n-1) nodes.
1. A program P reads in 500 integers in the range [0, 100], representing the
cores of 500 students. It then prints the frequency of each score above 50.
What would be the best way for P to store the frequencies?
a. An array of 50 numbers
b. An array of 100 numbers
c. An array of 500 numbers
d. A dynamically allocated array of 550 numbers
Answer (a)
2. A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks
grow from opposite ends of the array. Variables top1 and top2 (top1 < top2)
point to the location of the topmost element in each of the stacks. If the space
is to be used efficiently, the condition for “stack full” is ___________.
Answer (d)
3. Suppose you are given an array s[1..n] and a procedure reverse (s, i, j) which
reverses the order of elements in s between positions i and j (both inclusive).
What does the following sequence do, where 1 ≤ k < n: reverse (s, 1, k);
Answer (a)
a. 8
b. 13
c. 15
d. 20
Answer (b)
Which one of the following options is valid for the above two
statements?
Answer (c)
6. A hash table contains 10 buckets and uses linear probing to resolve collisions.
The key values are integers, and the hash function used is key % 10. If the
values 43, 165, 62, 123, 142 are inserted in the table, in what location would
the key value 142 be inserted?
(GATE CSE 2005)
a. 2
b. 3
c. 4
d. 6
Answer (d)
7. Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199)
and the hash function x mod 10, which of the following statements are true?
a. i only
b. ii only
c. i and ii only
d. iii or iv
Answer (c)
8. N items are stored in a sorted doubly linked list. For a delete operation, a
pointer is provided to the record to be deleted. For a decrease-key operation,
a pointer is provided to the record on which the operation is to be performed.
a. O(log2N)
b. O(N)
c. O(N2)
d. Θ(N2logN)
Answer (c)
Answer (d)
10. A queue is implemented using an array such that ENQUEUE and DEQUEUE
operations are performed efficiently. Which one of the following statements
is CORRECT (n refers to the number of items in the queue)?
Answer (a)
a. 6
b. 4
c. 3
d. 2
Answer (c)
Answer (a)
a. 5
b. 4
c. 10
d. 1
Answer (b)
a. Log n
b. n
c. 2n + 1
d. 2n – 1
Answer (b)
15. The following numbers are inserted into an empty binary search tree in the
given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search
tree (the height is the maximum distance of a leaf node from the root)?
a. 2
b. 3
c. 4
d. 5
Answer (b)
a. LIFO principle
b. FIFO principle
c. Linear tree
d. Ordered array
2. The time complexity used for inserting a node in a priority queue on the
basis of key is:
a. O(n)
b. O(n2)
c. O(nlogn)
d. O(logn)
a. a+b-c
b. +ab
c. abc*+de-+
d. a*b(c+d)
a. Heap
b. Tree
c. Priority queue
d. Stack
a. (2,8)
b. (8,5), (8,3)
a. X⊕0 = X
b. X⊕X = 0
c. X⊕0 = 1
d. (X⊕Y)⊕Z = X⊕(Y⊕Z)
b. K-ary Tree
c. Ternary Tree
d. AVL Tree
a. Hash table
b. Priority queue
d. Heap sort
11. Out of these, which one is NOT true about a 2-3 tree?
a. it is perfectly balanced
b. time complexity
a. create
b. find
c. delete
d. insert
15. The time does taken for the construction of suffix tree is:
c. O (M!)
d. O (log M)
a. Separate chaining
b. Double hashing
c. Linear probing
d. Quadratic probing
17. Which one is the most desirable out of these traits of a hash function?
18. What is the time complexity for checking if an undirected graph with E
edges and V vertices is Bipartite, given its adjacency matrix?
a. O(E)
b. O(V)
c. O(E*E)
d. O(V*V)
19. The members of two of the sets are relatively more common when the
Jaccard Index is:
a. Closer to 0
b. Closer to 1
c. Farther to 1
d. Closer to -1
a. Tautology Checking
b. Negation
c. Disjunction
d. Conjunction