Data Structures Test - 2 - PDF Flipbook

Data Structures Test - 2

277 Views
60 Downloads
PDF 5,219,264 Bytes

Download as PDF

REPORT DMCA


GATE
CSE

Data
Structures

Test-02Solutions


DATA STRUCTURES
1. A diametric projection is said to be trimetric projection when

i. Two of the three foreshortening factors are equal and third is
arbitrary.

ii. All of the three foreshortening factors are equal'
iii. All of the three foreshortening factors are arbitrary.

Which of the above is true?
a) (i) and (ii)
b) (ii) and (iii)
c) (i) only
d) (iii) only
Answer: (c)
Solution:
A dynamic projection is a special case of turmeric projection
where two of the three for shortening factors are equal and third
arbitrary. Therefore, only statement (i) is true.
2. Consider the following program fragment

i = 6720; j = 4;
while (i% j) ==0
{
i = i/j;
j = j+1;
}
On termination j will have the value
a) 4

1


b) 8

c) 9

d) 6720

Answer: (c)

Solution:

i = 6720, j = 4

(i % j) = 0; i = 1680 j=5

(i % j) = 0; i = 336 j=6

(i % j) = 0; i = 56 j=7

(i % j) = 0; i=8 j=8

(i % j) = 0; i=1 j=9

(i % j) ≠ 0

On termination the value of j is 9.

3. Queue is_____list.

a) LIFO

b) LILO

c) FILO

d) FIFO

Answer: (d)

Solution:

A queue is a data structure in which elements are removed in

the same order they were entered. This is often referred to as

FIFO (first in first out). Queue is also LILO (Last in last out)

structure.

2


A stack is a data structure in which elements are removed in the
reversed order from which they were entered. This is often
referred to as LIFO/FILO (last in first out)/ (first in last out)
4. The five items: A, B, C, D, and E are Q pushed in a stack, one
after other starting from A. The stack is popped four items and
each element is inserted in a queue. The two elements are
deleted from the queue and pushed back on the stack. Now one
item is popped from the stack. The popped item is
a) A
b) B
c) C
d) D
Answer: (d)
Solution:
Four items are pushed into stack A, B, C, D, E where Top is
pointing E. Now 4 elements are deleted and enqueue into queue.
So queue contain E, D, C, B where Rear is pointing B and Front
pointing E. Now two elements are deleted from the queue i.e. E
and 0respectively and pushed back on the stack i.e., e, d where
stack Top pointing 0now delete one element from stack gives O.
5. If each node in a tree has value greater than every value in its
left subtree and has value less than every value in its right
subtree, the tree is called
a) complete tree
b) full binary tree

3


c) binary search tree
d) threaded tree
Answer: (c)
6. Consider the following pseudo-code 4

x; = 1;
i; = 1;
While (x

Data Loading...