0 of 11 questions completed
Questions:
 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
Information
GATE Computer Science Test Description : Read carefully before you start.
Name : GATE CSE Online Practice Test Paper 1
Subject Covered : Programming, Graph Theory, Computer Networking
Questions: 12 Objective type
Marks Distribution: Question 1 to 05 : 1 mark / Question,
6 to 12 : 2 mark/question.
Negative Marking: 1/3 for 1 mark questions & 2/3 for 2 Mark questions.
Time Limit: 30 minutes
Important for : GATE Computer Science.
You have already completed the Test before. Hence you can not start it again.
Test is loading...
You must sign in or sign up to start the Test.
You have to finish following quiz, to start this Test:
Congratulations!!!" GATE CSE Online Practice Test Paper 1 "
0 of 11 questions answered correctly
Your time:
Time has elapsed
Your Final Score is : 0
You have attempted : 0
Number of Correct Questions : 0 and scored 0
Number of Incorrect Questions : 0 and Negative marks 0
Average score  
Your score 

Not categorized
You have attempted: 0
Number of Correct Questions: 0 and scored 0
Number of Incorrect Questions: 0 and Negative marks 0
It’s time to share this quiz with your friends on Facebook, Twitter, Google Plus, Whatsapp or LinkedIn…
Click on View Questions Button to check Correct and incorrect answers.
 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 Answered
 Review
 Question 1 of 11
1. Question
1 pointsMinimum number of temporary variables needed to swap the contents of two variables is
CorrectWithout any temporary variable, one can swap two given variables.
IncorrectWithout any temporary variable, one can swap two given variables.
UnattemptedWithout any temporary variable, one can swap two given variables.
 Question 2 of 11
2. Question
1 pointsWhat will be output if you will compile and execute the following C programming source code?
#include<stdio.h>
int main(){
int i=320;
char *ptr=(char *)&i;
printf(“%d”,*ptr);
return 0;
}CorrectAs we know size of int data type is two byte while char pointer can pointer one byte at time. Memory representation of int i=320
First Byte Second Byte 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ptr Sign bit So char pointer ptr is pointing to only first byte as shown above figure.
*ptr i.e. content of first byte is 01000000 and its decimal value is 64.IncorrectAs we know size of int data type is two byte while char pointer can pointer one byte at time. Memory representation of int i=320
First Byte Second Byte 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ptr Sign bit So char pointer ptr is pointing to only first byte as shown above figure.
*ptr i.e. content of first byte is 01000000 and its decimal value is 64.UnattemptedAs we know size of int data type is two byte while char pointer can pointer one byte at time. Memory representation of int i=320
First Byte Second Byte 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ptr Sign bit So char pointer ptr is pointing to only first byte as shown above figure.
*ptr i.e. content of first byte is 01000000 and its decimal value is 64.  Question 3 of 11
3. Question
1 pointsConsider an undirected random graph of eight vertices. The probability that there is an edge between a pair of vertices is 1/2. What is the expected number of unordered cycles of length three?
CorrectA cycle of length 3 can be formed with 3 vertices. There can be total 8C3 ways to pick 3 vertices from 8. The probability that there is an edge between two vertices is 1/2. So expected number of unordered cycles of length 3 = (8C3)*(1/2)^3 = 7
IncorrectA cycle of length 3 can be formed with 3 vertices. There can be total 8C3 ways to pick 3 vertices from 8. The probability that there is an edge between two vertices is 1/2. So expected number of unordered cycles of length 3 = (8C3)*(1/2)^3 = 7
UnattemptedA cycle of length 3 can be formed with 3 vertices. There can be total 8C3 ways to pick 3 vertices from 8. The probability that there is an edge between two vertices is 1/2. So expected number of unordered cycles of length 3 = (8C3)*(1/2)^3 = 7
 Question 4 of 11
4. Question
1 pointsWhat will be output if you will compile and execute the following C programming source code?
#include<stdio.h>
int main(){
int a=2;
if(a==2){
a=~a+2<<1;
printf(“%d”,a);
}
else{
break;
}
break;
return 0;
}CorrectKeyword break is not part of ifelse statement. Hence it will show compiler error: Misplaced break.
IncorrectKeyword break is not part of ifelse statement. Hence it will show compiler error: Misplaced break.
UnattemptedKeyword break is not part of ifelse statement. Hence it will show compiler error: Misplaced break.
 Question 5 of 11
5. Question
1 pointsConsider a B+tree in which the maximum number of keys in a node is 5. What is the minimum number of keys in any nonroot node?
CorrectSince the maximum number of keys is 5, maximum number of children a node can have is 6. By definition of B Tree, minimum children that a node can have would be 6/2 = 3. Therefore, minimum number of keys that a node can have becomes 2 (31).
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
IncorrectSince the maximum number of keys is 5, maximum number of children a node can have is 6. By definition of B Tree, minimum children that a node can have would be 6/2 = 3. Therefore, minimum number of keys that a node can have becomes 2 (31).
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
UnattemptedSince the maximum number of keys is 5, maximum number of children a node can have is 6. By definition of B Tree, minimum children that a node can have would be 6/2 = 3. Therefore, minimum number of keys that a node can have becomes 2 (31).
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
 Question 6 of 11
6. Question
2 pointsLet G = (V,E) be a graph. Define ξ(G) = Σd id x d, where id is the number of vertices of degree d in G. If S and T are two different trees with ξ(S) = ξ(T),then
CorrectThe expression ξ(G) is basically sum of all degrees in a tree. For example, in the following tree, the sum is 3 + 1 + 1 + 1.
a
/  \
b c dNow the questions is, if sum of degrees in trees are same, then what is the relationship between number of vertices present in both trees?
The answer is, ξ(G) and ξ(T) is same for two trees, then the trees have same number of vertices. It can be proved by induction. Let it be true for n vertices. If we add a vertex, then the new vertex (if it is not the first node) increases degree by 2, it doesn’t matter where we add it. For example, try to add a new vertex say ‘e’ at different places in above example tee.
IncorrectThe expression ξ(G) is basically sum of all degrees in a tree. For example, in the following tree, the sum is 3 + 1 + 1 + 1.
a
/  \
b c dNow the questions is, if sum of degrees in trees are same, then what is the relationship between number of vertices present in both trees?
The answer is, ξ(G) and ξ(T) is same for two trees, then the trees have same number of vertices. It can be proved by induction. Let it be true for n vertices. If we add a vertex, then the new vertex (if it is not the first node) increases degree by 2, it doesn’t matter where we add it. For example, try to add a new vertex say ‘e’ at different places in above example tee.
UnattemptedThe expression ξ(G) is basically sum of all degrees in a tree. For example, in the following tree, the sum is 3 + 1 + 1 + 1.
a
/  \
b c dNow the questions is, if sum of degrees in trees are same, then what is the relationship between number of vertices present in both trees?
The answer is, ξ(G) and ξ(T) is same for two trees, then the trees have same number of vertices. It can be proved by induction. Let it be true for n vertices. If we add a vertex, then the new vertex (if it is not the first node) increases degree by 2, it doesn’t matter where we add it. For example, try to add a new vertex say ‘e’ at different places in above example tee.
 Question 7 of 11
7. Question
2 pointsWhat will be output if you will compile and execute the following C programming source code?
#include<stdio.h>
int main(){
int x;
for(x=1;x<=5;x++);
printf(“%d”,x);
return 0;
}CorrectBody of for loop is optional. In this question for loop will execute until value of variable x became six (6) and condition became false.
IncorrectBody of for loop is optional. In this question for loop will execute until value of variable x became six (6) and condition became false.
UnattemptedBody of for loop is optional. In this question for loop will execute until value of variable x became six (6) and condition became false.
 Question 8 of 11
8. Question
2 pointsIf the following program fragment (assume negative numbers are stored in 2’s complement form)
unsigned i = 1;
int j = 4;
printf(“%d”,8*size of (int));
output is (lot in the answers are to the base two)CorrectLet size of (int)=1. So, 4 will be stored 11111100. Since we are adding unsigned and signed integers, the signed gets converted to unsigned. So, i+j will become 11111101. We are trying to print this as an unsigned integer.
So, what is printed will be 2^{8} – 1 – 2. So, log (x+3)=8 (i.e., *size of (int)).IncorrectLet size of (int)=1. So, 4 will be stored 11111100. Since we are adding unsigned and signed integers, the signed gets converted to unsigned. So, i+j will become 11111101. We are trying to print this as an unsigned integer.
So, what is printed will be 2^{8} – 1 – 2. So, log (x+3)=8 (i.e., *size of (int)).UnattemptedLet size of (int)=1. So, 4 will be stored 11111100. Since we are adding unsigned and signed integers, the signed gets converted to unsigned. So, i+j will become 11111101. We are trying to print this as an unsigned integer.
So, what is printed will be 2^{8} – 1 – 2. So, log (x+3)=8 (i.e., *size of (int)).  Question 9 of 11
9. Question
2 pointsConsider the following program:
main()
{
putchar(‘M’);
first();
putchar(‘m’)}
first()
{——————}
second()
{
putchar(‘d’);
}
If, madam is the required output, then the body of first() must beCorrectSince Madam is the required output, the function first(), should print ‘a’, call the function second() that prints the ‘d’ and print ‘a’ again. Hence putchar(‘a’); second(); printf(“%c”,’a’); means option c is the correct answer.
IncorrectSince Madam is the required output, the function first(), should print ‘a’, call the function second() that prints the ‘d’ and print ‘a’ again. Hence putchar(‘a’); second(); printf(“%c”,’a’); means option c is the correct answer.
UnattemptedSince Madam is the required output, the function first(), should print ‘a’, call the function second() that prints the ‘d’ and print ‘a’ again. Hence putchar(‘a’); second(); printf(“%c”,’a’); means option c is the correct answer.
 Question 10 of 11
10. Question
2 pointsStation A uses 32 byte packets to transmit messages to Station B using a sliding window protocol. The round trip delay between A and B is 80 milliseconds and the bottleneck bandwidth on the path between A and B is 128 kbps. What is the optimal window size that A should use?
CorrectRound Trip propagation delay = 80ms
Frame size = 32*8 bits
Bandwidth = 128kbps
Transmission Time = 32*8/(128) ms = 2 ms
Let n be the window size.
UtiliZation = n/(1+2a) where a = Propagation time / transmission time
= n/(1+80/2)For maximum utilization: n = 41 which is close to option (B).
IncorrectRound Trip propagation delay = 80ms
Frame size = 32*8 bits
Bandwidth = 128kbps
Transmission Time = 32*8/(128) ms = 2 ms
Let n be the window size.
UtiliZation = n/(1+2a) where a = Propagation time / transmission time
= n/(1+80/2)For maximum utilization: n = 41 which is close to option (B).
UnattemptedRound Trip propagation delay = 80ms
Frame size = 32*8 bits
Bandwidth = 128kbps
Transmission Time = 32*8/(128) ms = 2 ms
Let n be the window size.
UtiliZation = n/(1+2a) where a = Propagation time / transmission time
= n/(1+80/2)For maximum utilization: n = 41 which is close to option (B).
 Question 11 of 11
11. Question
2 pointsConsider the C program below.
#include <stdio.h>
int *A, stkTop;
int stkFunc(int opcode, int val)
{
static int size=0, stkTop=0;
switch (opcode) {
case 1: size = val; break;
case 0: if (stkTop < size) A[stkTop++] = val; break;
default: if (stkTop) return A[–stkTop];
}
return 1;
}
int main()
{
int B[20]; A = B; stkTop = 1;
stkFunc (1, 10);
stkFunc ( 0, 5);
stkFunc ( 0, 10);
printf (“%d\n”, stkFunc(1, 0) + stkFunc(1, 0));
}The value printed by the above program is __________.
CorrectThe code in main, basically initializes a stack of size 10, then pushes 5, then pushes 10.
Finally the printf statement prints sum of two pop operations which is 10 + 5 = 15.
stkFunc (1, 10); // Initialize size as 10
stkFunc (0, 5); // push 5
stkFunc (0, 10); // push 10
// print sum of two pop
printf (“%d\n”, stkFunc(1, 0) + stkFunc(1, 0));IncorrectThe code in main, basically initializes a stack of size 10, then pushes 5, then pushes 10.
Finally the printf statement prints sum of two pop operations which is 10 + 5 = 15.
stkFunc (1, 10); // Initialize size as 10
stkFunc (0, 5); // push 5
stkFunc (0, 10); // push 10
// print sum of two pop
printf (“%d\n”, stkFunc(1, 0) + stkFunc(1, 0));UnattemptedThe code in main, basically initializes a stack of size 10, then pushes 5, then pushes 10.
Finally the printf statement prints sum of two pop operations which is 10 + 5 = 15.
stkFunc (1, 10); // Initialize size as 10
stkFunc (0, 5); // push 5
stkFunc (0, 10); // push 10
// print sum of two pop
printf (“%d\n”, stkFunc(1, 0) + stkFunc(1, 0));