wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

EC8393_FDS_MODEL EXAM_3_PART B

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.

#include <stdio.h>

int main()

{

int i,j=8;

if (printf("%d",j))

i = 3;

else

i = 5;

printf("%d", i);

return 0;

}

Predict the output of above program?

a)

3

b)

5

c)

83

d)

85

2.

#include <stdio.h>

int main()

{

int arr[5];

// Assume base address of arr is 2000 and size of integer is 4 bytes

printf("%u %u", arr + 1, &arr + 1);

return 0;

}

Predict the output of above program?

a)

2004 2020

b)

2004 2004

c)

2004 Garbage value

d)

The program fails to compile because Address-of operator cannot be used with array name

3.

#include<stdio.h>


int main()

{

int a[5] = {5, 1, 15, 20, 25};

int i, j, m;

i = ++a[1];

j = a[1]++;

m = a[i++];

printf("%d, %d, %d", i, j, m);

return 0;

}

Predict the output of above program?

a)

2,5,15

b)

3, 2, 15

c)

1,2,5

d)

12,15,1

4.

struct node { int i; float j; }; struct node *s[10];

The above C declaration define ‘s’ to be

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.

5.

struct { short s[5]; union { float y; long z; }u; } t;

Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations, is

a)

22 bytes

b)

14 bytes

c)

18 bytes

d)

10 bytes

6.

struct st { int x; struct st next; }; int main() { struct st temp; temp.x = 10; temp.next = temp; printf("%d", temp.next.x); return 0; }

a)

Compiler Error

b)

10

c)

Runtime Error

d)

Garbage Value

7.

Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an initially empty binary search tree. The binary search tree uses the usual ordering on natural numbers. What is the in-order traversal sequence of the resultant tree?

a)

0 1 2 3 4 5 6 7 8 9

b)

0 2 4 3 1 6 5 9 8 7

c)

7 5 1 0 3 2 4 6 8 9

d)

9 8 6 4 2 3 0 1 5 7

8.

The post-order traversal of a binary search tree is given by 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12.

Then the pre-order traversal of this tree is:

a)

2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20

b)

7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12

c)

7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12

d)

12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20

9.

How many distinct binary search trees can be created out of 4 distinct keys?

a)

35

b)

14

c)

24

d)

5

10.

Postfix form of following expression D + (E * F) is

a)

EF*+D

b)

DEF*+

c)

DEF+*

d)

None

11.

What will be the value of top, if there is a size of stack STACK_SIZE is 5

a)

5

b)

6

c)

4

d)

None

12.

Following sequence of operations is performed on a stack push(1),push(2),pop, push(1),push(2)pop,pop,pop,push(2),pop.The sequence of poped out values are

a)

2,1,2,,1,2

b)

2,1,,2,1,2

c)

2,2,1,1,2

d)

2,2,1,2,2

13.

Find the pivot element from the given input using median-of-three partitioning method.

8, 1, 4, 9, 6, 3, 5, 2, 7, 0.

a)

8

b)

7

c)

9

d)

6

14.

A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below.


Which one of the following choices gives a possible order in which the key values could have been inserted in the table?

a)

46, 42, 34, 52, 23, 33

b)

34, 42, 23, 52, 33, 46

c)

46, 34, 42, 23, 52, 33

d)

42, 46, 33, 23, 34, 52

15.

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?

i. 9679, 1989, 4199 hash to the same value

ii. 1471, 6171 hash to the same value

iii. All elements hash to the same value

iv. Each element hashes to a different value

a)

i only

b)

ii only

c)

i and ii only

d)

iii or iv