NEW
Font size
WorksheetsEC8393_FDS_MODEL EXAM_3_PART B
Total questions: 15
Worksheet time: 15mins
#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?
3
5
83
85
#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?
2004 2020
2004 2004
2004 Garbage value
The program fails to compile because Address-of operator cannot be used with array name
#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?
2,5,15
3, 2, 15
1,2,5
12,15,1
struct node { int i; float j; }; struct node *s[10];
The above C declaration define ‘s’ to be
An array, each element of which is a pointer to a structure of type node
A structure of 2 fields, each field being a pointer to an array of 10 elements
A structure of 3 fields: an integer, a float, and an array of 10 elements
An array, each element of which is a structure of type node.
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
22 bytes
14 bytes
18 bytes
10 bytes
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; }
Compiler Error
10
Runtime Error
Garbage Value
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?
0 1 2 3 4 5 6 7 8 9
0 2 4 3 1 6 5 9 8 7
7 5 1 0 3 2 4 6 8 9
9 8 6 4 2 3 0 1 5 7
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:
2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20
7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12
7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12
12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20
How many distinct binary search trees can be created out of 4 distinct keys?
35
14
24
5
Postfix form of following expression D + (E * F) is
EF*+D
DEF*+
DEF+*
None
What will be the value of top, if there is a size of stack STACK_SIZE is 5
5
6
4
None
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
2,1,2,,1,2
2,1,,2,1,2
2,2,1,1,2
2,2,1,2,2
Find the pivot element from the given input using median-of-three partitioning method.
8, 1, 4, 9, 6, 3, 5, 2, 7, 0.
8
7
9
6
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?
46, 42, 34, 52, 23, 33
34, 42, 23, 52, 33, 46
46, 34, 42, 23, 52, 33
42, 46, 33, 23, 34, 52
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
i only
ii only
i and ii only
iii or iv
