wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CODEZILLA 2022

Total questions: 30

Worksheet time: 28mins

Name
Class
Date
1.

The minimum number of stacks needed to implement a queue is

a)

3

b)

1

c)

2

d)

4

2.

The operating system of a computer may periodically collect all the deleted space onto the free storage list and this technique is called ___.

a)

Memory management

b)

Garbage Collection

c)

Memory allocation

d)

Memory Deallocation

3.

Before executing push operation one must check for the ___ condition.

a)

Underflow

b)

Overflow

c)

Full

d)

Empty

4.

 Incomplete tree is very efficient in memory management.

a)

True

b)

False

5.

 Full form of PERT is

a)

Program Evaluation and Review Technique

b)

Process Evaluation and Review Technique

c)

Program Effective and Review Technique

d)

Process Effective and Review Technique

6.

Which one of the following is an application of Queue Data Structure?

a)

When a resource is shared among multiple consumers.

b)

When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes

c)

Load Balancing

d)

All of the above

7.

Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?

a)

Insertion Sort

b)

Quick Sort

c)

Heap Sort

d)

Merge Sort

8.

Which of the following is an advantage of adjacency list representation over adjacency matrix representation of a graph?

a)

In adjacency list representation, space is saved for sparse graphs.

b)

DFS and BSF can be done in O(V + E) time for adjacency list representation. These operations take O(V^2) time in adjacency matrix representation. Here is V and E are number of vertices and edges respectively.

c)

Adding a vertex in adjacency list representation is easier than adjacency matrix representation.

d)

All of the above

9.

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 2 4 3 1 6 5 9 8 7

b)

9 8 6 4 2 3 0 1 5 7

c)

7 5 1 0 3 2 4 6 8 9

d)

0 1 2 3 4 5 6 7 8 9

10.

Let G be a weighted undirected graph and e be an edge with maximum weight in G. Suppose there is a minimum weight spanning tree in G containing the edge e. Which of the following statements is always TRUE?  

a)

There exists a cutset in G having all edges of maximum weight

b)

There exists a cycle in G having all edges of maximum weight

c)

Edge e cannot be contained in a cycle.

d)

All edges in G have the same weight

11.

Examine the output of following:-

#include stdio.h

int main()

{

int x, y = 5, z = 5;

x = y == z;

printf("%d", x);

getchar()

return 0;

}

a)

0

b)

1

c)

5

d)

Compilation Error

12.

#include <stdio.h>

int main()

{

  char arr[] = "HelloQuiz";

  printf("%s", ?);

  return 0;

}

In above program, what would you put in place of “?” to print “Quiz”?

a)

arr

b)

(arr+4)

c)

(arr+5)

d)

Not Possible

13.

Predict the output of following program, assume that a character takes 1 byte and pointer takes 4 bytes

#include<stdio.h>

int main()

{

char *str1 = "HelloQuiz"; 

  char str2[] = "HelloQuiz";    

printf("sizeof(str1) = %d, sizeof(str2) = %d",

sizeof(str1), sizeof(str2));    

return 0;

}

a)

sizeof(str1) = 10, sizeof(str2) = 10

b)

sizeof(str1) = 4, sizeof(str2) = 4

c)

sizeof(str1) = 10, sizeof(str2) = 4

d)

sizeof(str1)=4,

sizeof(str2)=10

14.

What does the following program print?

#include

void f(int p, int q)

{

  p = q;

 *p = 2;

}

int i = 0, j = 1;

int main()

{

  f(&i, &j);

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

  getchar();

  return 0;

}

a)

22

b)

21

c)

01

d)

02

15.

Examine the output of the following:-

#include <stdio.h>

int main()

{

unsigned int i = 65000;

while (i++ != 0);

printf("%d", i);

return 0;

}

a)

Infinite Loop

b)

0

c)

1

d)

RunTime Error

16.

Examine the output of the following:-

#include <stdio.h>

int main()

{

char arr[]={ 'A', 'B', 'c', 'd', 'E', 'f' };

int size=sizeof(arr)/sizeof(arr[0]);

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

return 0;

}

a)

0

b)

6

c)

12

d)

1

17.

Examine the output of the following:-

#include <stdio.h>

int main()

{

int a[2][2] = { 1, 2, 3, 4 };

int *p;

p= &a[1][1];

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

return 0;

}

a)

1

b)

2

c)

3

d)

4

18.

Examine the output of the following:-

#include <stdio.h>


int main()

{

int p = 4, q, r;


q = p = 15;

r = p < 15;


printf("p = %d q = %d r = %d\n", p, q, r);


return 0;

}

a)

p = 15 q = 15 r = 0

b)

p=0 q= 0 r = 15

c)

p = 0 q = 15 r = 0

d)

p=15 q = 0 r = 15

19.

Examine the output of the following:-

#include <stdio.h>


int main()

{

int i;

for(i=1; -1; i++)

printf("%c ",i);

return 0;

}

a)

1 2 3 4

b)

error

c)

1 2 3

d)

1 2 3 4 .... infinite times

20.

Examine the output of the following:-

#include<stdio.h>

int main()

{

int i = 1, j = 1;

for(--i && j++ ; i<10; i+=2)

{

printf("loop ");

}

return 0;

}

a)

Compilation error

b)

Program never ends

c)

loop loop loop loop loop

d)

None of the above

21.

Predict the error in the following piece of code:-

#include<stdio.h>


int main()

{

char ch;

int i;

scanf("%c", &i);

scanf("%d", &ch);

printf("%c %d", ch, i);

return 0;

}

a)

Error: suspicious char to in conversion in scanf()

b)

Error: we may not get input for second scanf() statement

c)

No error

d)

None of above

22.

Predict the error in the following piece of code:-

#include<stdio.h>


/* Assume there is a file called 'file.c' in c:\tc directory. */

int main()

{

FILE *fp;

fp=fopen("c:\tc\file.c", "r");

if(!fp)

printf("Unable to open file.");


fclose(fp);

return 0;

}

a)

No error, No output.

b)

Program crashes at run time

c)

Output unable to open file

d)

None of the above

23.

Predict the error in the following piece of code:-

#include<stdio.h>


int main()

{

unsigned char ch;

FILE *fp;

fp=fopen("trial", "r");

while((ch = getc(fp))!=EOF)

printf("%c", ch);

fclose(fp);

return 0;

}

a)

Error: in unsigned char declaration

b)

Error: while statement

c)

No error

d)

It prints all characters in file "trial"

24.

Predict the error in the following piece of code:-

f(int a, int b)

{

int a;

a = 20;

return a;

}

a)

Missing parenthesis in return statement

b)

The function should be defined as int f(int a, int b)

c)

Redeclaration of a

d)

None of above

25.

Predict the error in the following piece of code:-

#include<stdio.h>

int f(int a)

{

a > 20? return(10): return(20);

}

int main()

{

int f(int);

int b;

b = f(20);

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

return 0;

}

a)

Error: Prototype declaration

b)

No error

c)

Error: return statement cannot be used with conditional operators

d)

None of the above

26.

Predict the error in the following piece of code:-

#include<stdio.h>


int main()

{

int a=10;

void f();

a = f();

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

return 0;

}

void f()

{

printf("Hi");

}

a)

Error: Not allowed assignment

b)

Error: Doesn't print anything

c)

No error

d)

None of above

27.

Predict the error in the following piece of code:-

#include<stdio.h>

int main()

{

display();

return 0;

}

void display()

{

printf("Codezilla 2022");

}

a)

No error

b)

display() doesn't get invoked

c)

display() is called before it is defined

d)

None of these

28.

#include<stdio.h>

struct emp

{

char name[20];

int age;

};

int main()

{

emp int xx;

int a;

printf("%d\n", &a);

return 0;

}

a)

Error: in printf

b)

Error: in emp int xx, add struct before emp to fix;

c)

No error.

d)

None of these.

29.

#include<stdio.h>

int main()

{

int (*p)() = fun;

(*p)();

return 0;

}

int fun()

{

printf("Codezilla 2022\n");

return 0;

}

a)

Error: in int(*p)() = fun;

b)

Error: fun() prototype not defined

c)

No error

d)

None of these

30.

#include <stdio.h>


void main()

{

int a = 0;

for (int a = 9; a < 10; a ++)

{

printf("%d",a);

}

}

a)

Syntax Error

b)

Error: redefinition of ‘a’

c)

No Error and Correct Output

d)

No Error and No Output