The inorder traversal of the tree will yield a sorted sequence of elements of the tree in ___
Binary tree
Binary Search Tree
Ternary tree
Heaps
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
What will be the result of following postfix expression ___?

1 4 18 6 / 3 + + 5 / +

3
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
void fun(int, long);

void fun(int x, long y)

{}

void main ()

{

int i = 10;

long j = 120;

long *p = &j;

__________ ; // call to fun() from main

}

Which one of the following expressions, when placed in the blank above, will NOT result in an error?

fun( j, *j)
i = fun (i,j)
fun(i, *j)
fun(i, *p)
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
#include<stdio.h>

void count(int n) {

static int d=1;

printf("%d ", n);

printf("%d ", d);

d++;

if(n>2) count(n-1);

printf("%d ", d);

}

void main() {

count(3);

}

What will be the output of above program?

3 1 2 2 1 3 4 4 4
3 1 2 2 3 3
3 1 2 2 1 3 4
3 1 2 1 1 1 2
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Consider the usual algorithm for determining whether a sequence of parenthesis is balanced. What is the maximum number of parenthesis that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: ( ( ) ( ( ) ) ( ( ) ) )

Pseudocode:

str [ ] = sequence of parenthesis

while (str[i])

{ if (open parenthesis) push into stack;

else

pop( )

}

1
2
3
4
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Consider the C function given below.

int fun(int j)

{

static int i = 30;

int k;

if (i == j)

{

printf("something");

k = fun(i);

return 0;

}

else return 0;

}

Which one of the following is TRUE?

The function returns 0 for all values of j.
The function prints the string something for all values of j.
The function returns 0 when j = 30.
The function will exhaust the runtime stack or run into an infinite loop when j = 30
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
data type (*var name)[size of array];

The above declaration syntax is for:

Pointer to an array
Array of pointers
Pointer to a variable
None
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
The sequence of elements 76, 84, 52, 74, 2, 42, 40 are inserted in an empty AVL tree. There will be X imbalances occur after insertion of Y set of elements in the tree, which will be balanced after rotations. What are the values of X and Y respectively.
X=0 imbalances; Y= No rotations required
X= 1 imbalance; Y = rotation required after insertion of 2
X= 2 imbalances; Y= rotations required after insertion of 2 and 42
X= 2 imbalances; Y= rotations required after insertion of 42 and 40
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Assume int is 4 bytes, char is 1 byte and float is 4 bytes. Also, assume that pointer size is 4 bytes (i.e. typical case)

char *ch;

int *in;

float *fl;

sizeof(ch);

sizeof(in);

sizeof(fl);

What’s the size returned for each of sizeof() operator?

4 4 4
1 4 4
1 4 8
None
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
#include<stdio.h>

void fun1(char* s1, char* s2){

char* temp;

temp = s1;

s1 = s2;

s2 = temp;

}

void fun2(char** s1, char** s2){

char* temp;

temp = *s1;

*s1 = *s2;

*s2 = temp;

}

int main(){

char *t1="Corona", *t2 = "Go";

fun1(t1, t2); printf("%s %s", t1, t2);

fun2(&t1, &t2); printf("%s %s", t1, t2);

return 0;

}

The output of the program above is:

Corona Go Go Corona
Corona Go Corona Go
Go Corona Corona Go
Go Corona Go Corona
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
In C, lets assume an array A[20][10]. Assume 4 words per memory cell, elements are stored in row-major order. What is the address of A[11][5] ?

Note: consider base address to be 100, and array indexing starts from [0,0]

560
460
570
575
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
#include<stdio.h>

void main()

{

int arr[3][3]={1,2,3,4,5,6,7,8,9};

printf("%d",arr[2]);

}

What is the output of the above code?

Memory address of ‘7’ value
Memory address of ‘3’ value
Compiler error
3 will be printed
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
What is the output of the following program?

#include<stdio.h>

void main()

{

char s[100];

s="Gate";

printf("%s",s);

}

Gate
G
Compiler error
71
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
int find(int x, int y){

return( (x<y) ? 0 : (x-y) );

}

void main()

{

int x=5, y=9,z;

Z = find(5,9);

}

Let x,y are non-negative numbers and if we call find(x, find(x,y)),then What is the Output of above code:

Find max of (x,y)
Find min of (x,y)
Sum of (x,y)
Finds |x-y|
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
typedef struct Record

{

char ename[30];

int ssn;

int deptno;

} employee;

Choose incorrect statement about above snippet of code:

Tag name is not optional in Structure declaration
Employee is new data type
We can create variables of type ‘employee’
The code won’t have any error even if we remove ‘typedef’ from the declaration of the structure.
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
What will be the output of the following program?

#include<stdio.h>

void main()

{

int a = 5;

int *ptr = NULL;

printf("%d\n",*ptr);

}

5
0
NULL
Segmentation fault
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Consider the following program.

#include <stdio.h>

void my_fun(int x){

printf( "%d\n", x );

}

int main(){

void (*fptr)(int);

A ; // Initializing Function Pointers

fptr( 2 );

return 0;

}

What can be the statement A?

1) A : fptr = &my_fun

2) A : fptr = my_fun

3) A : *fptr = my_fun

4) A : *fptr = &my_fun

1&2
1&3
1 &4
2&4
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Suppose the numbers 17, 15, 11, 18, 13, 16, 10, 19, 14, 12 are inserted in that order into an initially empty binary search tree. The binary search tree uses the reversal ordering on natural numbers i.e. 19 is assumed to be smallest and 10 is assumed to be largest. The inorder traversal of the resultant binary search tree is
19, 18, 16, 14, 12, 13, 10, 11, 15, 17
10, 11, 12, 13, 14, 15, 16, 17, 18, 19
10, 12, 14, 13, 11, 16, 15, 19, 18, 17
19, 18, 17, 16, 15, 14, 13, 12, 11, 10
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66

The inorder traversal of a BST is 11, 12, 13, 16, 24, 26 and pre-order traversal is 24, 12, 11, 16, 13, 26.

If we remove the root node , then which of the following from the left subtree will be the new root?

16
12
26
13
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66

The inorder traversal of a BST is 11, 12, 13, 16, 24, 26 and the preorder traversal of the same tree is: 16, 12, 11, 13, 26, 24.

If the root node is deleted then what will be the next root of the resultant tree?

(i) 13 (ii) 24 (iii) 11 (iv) 26

(i) or (ii)
(i) or (iv)
(ii) or (iii)
(ii) or (iv)
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
struct Node

{

int data;

struct Node *next;

};

void fun(struct Node* prev_node, int new_data)

{

/*1. check if the given prev_node is NULL */

if (prev_node == NULL)

{

printf("the given previous node cannot be NULL");

return;

}

struct Node* new_node =(struct Node*) malloc(sizeof(struct Node));

new_node->data = new_data;

prev_node->next = new_node;

new_node->next = prev_node->next;

}

void main()

{

struct Node* head=NULL;

struct Node* N1=NULL;

struct Node* N2=NULL;

struct Node* N3=NULL;


head=(struct Node*)malloc(sizeof(struct Node));

N1=(struct Node*)malloc(sizeof(struct Node));

N2 = (struct Node*)malloc(sizeof(struct Node));

N3 = (struct Node*)malloc(sizeof(struct Node));


head -> data = 0;

N1 -> data =1;

N2 -> data =2;

N3 -> data =3;

head -> next = N1;

N1 -> next = N2;

N2 -> next = N3;

N3 -> next =NULL;

fun(N2, 10);

}

What does the above code do?

It adds a node of data 10 in after N2 with formation of new linked list without losing any node earlier
It adds a node of data 10 in before N2 with formation of new linked list
It adds a node of data 10 in the middle of the linked list irrespective of N2 node.
None of the above
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66

Which among the following is primitive data structure? [MSQ]

Double

Tree

Array

Queue

Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
Consider a full ternary tree having 4 internal nodes. What will be the total number of leaves to this tree? ____

Note: Full ternary tree is a tree whose all nodes have 0 or 3 children

9
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
struct node

{

int data; // Data

node *bwd; // A reference to the previous node

node *fwd; // A reference to the next node

};

Consider a doubly linked list, which has a pointer named ‘rearmost’, which is pointing to the last element of the list. Which among the following segments of code deletes the element pointed by ‘rearmost’?

rearmost -> bwd -> fwd = NULL;
rearmost -> fwd -> bwd = NULL;
rearmost -> bwd -> fwd = rearmost -> bwd;
rearmost -> fwd -> bwd = rearmost -> bwd;
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider an one dimensional integer array whose index starts with 1. What is the address of ith element in the array if the base address is T and size of integer is S bytes?
T + (i-1)S
T + i * S
S + (i-1)T
S + i * T
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Given a simple undirected graph with n vertices such that every possible pair of vertices is connected with an edge. How many DFS traversals are possible for such a graph?
N^2
N!
N(N-1)
N(N-1)/2
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
The Pr-eorder and inorder traversal of a Binary tree is as follows:

A B X E M S W T P N C H

E X M B S A P T N W H C

The post-order traversal of the tree is?

H C N P T W S M E X B A
H N C P T W S M E X B A
E M X S N P B T H C W A
E M X S B P N T H C W A
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Which among the following segments of code counts the number of elements in the doubly linked list if it is assumed that X points to be first element of the list & ctr if the variable which counts the number of elements in the list?

struct node

{

int data; // Data

node *bwd; // A reference to the previous node

node *fwd; // A reference to the next node

};

for (ctr = 1; X != NULL; ctr++) X = X ➝ bwd;
for (ctr = 1; X ➝ fwd != NULL; ctr++) X = X ➝ fwd;
for (ctr = 1; X ➝ bwd != NULL; ctr++) X = X ➝ bwd;
for (ctr = 1; X != NULL; ctr++) X = X ➝ fwd;
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Which of the following sequences of keys gives the same resultant AVL tree?

I) 7, 6, 5, 4, 3, 2, 1

II) 1, 2, 3, 4, 5, 6, 7

III) 4, 2, 6, 1, 3, 5, 7

IV) 4, 6, 2, 5, 3, 1, 7

I and II only
III and IV only
I and IV only
All of these
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
A circular queue ‘q’ is of size 9 elements. Queue ‘q’ is initially empty and has indices from 0 to 7.

for(i = 1, i< = 8; i++)

q.enqueue(i);

for ( i = 1; i<=7; i++)

{

q.dequeue();

q.enqueue(q.dequeue());

}

Assume enqueue and dequeue are circular operations for insertion and deletion respectively. The number of elements that will remain in the queue after the completion of the program is ___________

0
1
2
3
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
How many labeled Binary Trees can be there with 3 nodes?
14
30
24
18
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
How many distinct BST can be created out of 5 distinct keys?
48
42
1040
1046
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
What is the output of following program?

#include<stdio.h>

void print(char *a)

{

if (*a && *a != '*')

{

print(a+2);

putchar(*a);

}

}

void main()

{

print("123456*");

}

642
531
135
246
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66