NEW
Font size
WorksheetsCODEZILLA 2022
Total questions: 30
Worksheet time: 28mins
The minimum number of stacks needed to implement a queue is
3
1
2
4
The operating system of a computer may periodically collect all the deleted space onto the free storage list and this technique is called ___.
Memory management
Garbage Collection
Memory allocation
Memory Deallocation
Before executing push operation one must check for the ___ condition.
Underflow
Overflow
Full
Empty
Incomplete tree is very efficient in memory management.
True
False
Full form of PERT is
Program Evaluation and Review Technique
Process Evaluation and Review Technique
Program Effective and Review Technique
Process Effective and Review Technique
Which one of the following is an application of Queue Data Structure?
When a resource is shared among multiple consumers.
When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes
Load Balancing
All of the above
Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
Insertion Sort
Quick Sort
Heap Sort
Merge Sort
Which of the following is an advantage of adjacency list representation over adjacency matrix representation of a graph?
In adjacency list representation, space is saved for sparse graphs.
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.
Adding a vertex in adjacency list representation is easier than adjacency matrix representation.
All of the above
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 2 4 3 1 6 5 9 8 7
9 8 6 4 2 3 0 1 5 7
7 5 1 0 3 2 4 6 8 9
0 1 2 3 4 5 6 7 8 9
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?
There exists a cutset in G having all edges of maximum weight
There exists a cycle in G having all edges of maximum weight
Edge e cannot be contained in a cycle.
All edges in G have the same weight
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;
}
0
1
5
Compilation Error
#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”?
arr
(arr+4)
(arr+5)
Not Possible
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;
}
sizeof(str1) = 10, sizeof(str2) = 10
sizeof(str1) = 4, sizeof(str2) = 4
sizeof(str1) = 10, sizeof(str2) = 4
sizeof(str1)=4,
sizeof(str2)=10
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;
}
22
21
01
02
Examine the output of the following:-
#include <stdio.h>
int main()
{
unsigned int i = 65000;
while (i++ != 0);
printf("%d", i);
return 0;
}
Infinite Loop
0
1
RunTime Error
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;
}
0
6
12
1
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;
}
1
2
3
4
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;
}
p = 15 q = 15 r = 0
p=0 q= 0 r = 15
p = 0 q = 15 r = 0
p=15 q = 0 r = 15
Examine the output of the following:-
#include <stdio.h>
int main()
{
int i;
for(i=1; -1; i++)
printf("%c ",i);
return 0;
}
1 2 3 4
error
1 2 3
1 2 3 4 .... infinite times
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;
}
Compilation error
Program never ends
loop loop loop loop loop
None of the above
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;
}
Error: suspicious char to in conversion in scanf()
Error: we may not get input for second scanf() statement
No error
None of above
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;
}
No error, No output.
Program crashes at run time
Output unable to open file
None of the above
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;
}
Error: in unsigned char declaration
Error: while statement
No error
It prints all characters in file "trial"
Predict the error in the following piece of code:-
f(int a, int b)
{
int a;
a = 20;
return a;
}
Missing parenthesis in return statement
The function should be defined as int f(int a, int b)
Redeclaration of a
None of above
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;
}
Error: Prototype declaration
No error
Error: return statement cannot be used with conditional operators
None of the above
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");
}
Error: Not allowed assignment
Error: Doesn't print anything
No error
None of above
Predict the error in the following piece of code:-
#include<stdio.h>
int main()
{
display();
return 0;
}
void display()
{
printf("Codezilla 2022");
}
No error
display() doesn't get invoked
display() is called before it is defined
None of these
#include<stdio.h>
struct emp
{
char name[20];
int age;
};
int main()
{
emp int xx;
int a;
printf("%d\n", &a);
return 0;
}
Error: in printf
Error: in emp int xx, add struct before emp to fix;
No error.
None of these.
#include<stdio.h>
int main()
{
int (*p)() = fun;
(*p)();
return 0;
}
int fun()
{
printf("Codezilla 2022\n");
return 0;
}
Error: in int(*p)() = fun;
Error: fun() prototype not defined
No error
None of these
#include <stdio.h>
void main()
{
int a = 0;
for (int a = 9; a < 10; a ++)
{
printf("%d",a);
}
}
Syntax Error
Error: redefinition of ‘a’
No Error and Correct Output
No Error and No Output
