Time Left - 15:00 mins
GATE 2019 - Programming & Data Structure Quiz-1 (App update required to attempt this test)
Attempt now to get your rank among 1911 students!
Question 1
Consider the following two C code segments. Y and X are one and two-dimensional arrays of size n and n × n respectively, where 2 ≤ n ≤ 10. Assume that in both code segments, elements of Y are initialized to 0 and each element X[i][j] of array X is initialized to i + j. Further assume that when stored in main memory all elements of X are in same main memory page frame.
Code segment 1: // initialize elements of Y to 0 // initialize elements X[i][j] of X to i+j for (i = 0; i < n; i++) y[i] + = X[0][i]; Code segment 2: // initialize elements of Y to 0 // initialize elements X[i][j] of X to i+j for (i = 0; i < n; i++) y[i] + = X[i][0]; |
Which of the following statements is/are correct?
S1: Final contents of array Y will be same in both code segments. S2: Elements of array X accessed inside the for loop shown in code segment 1 are contiguous in main memory. S3: Elements of array X accessed inside the for loop shown in code segment 2 are contiguous in main memory.
Question 2
If only the root node does not satisfy the heap property, the algorithm to convert the complete binary tree into a heap has the best asymptotic time complexity of
Question 3
#include <iostream>
using namespace std;
int main(){
int x=12,y=16;
char *p;
string s;
p=new char[y-x];
p[1]='c';
p[0]='h';
p[3]='l';
p[2]='f';
s=p;
cout<<s;
return 0;
}
What will be output of above code ?
using namespace std;
int main(){
int x=12,y=16;
char *p;
string s;
p=new char[y-x];
p[1]='c';
p[0]='h';
p[3]='l';
p[2]='f';
s=p;
cout<<s;
return 0;
}
What will be output of above code ?
Question 4
Let G(x) = a/(1 – x)2 = , where | x | < 1. What is g(i) ?
Question 5
Let q be a queue and S be a stack. Assume that q and S are initially empty. What is the last integer value printed by the following code?
Enqueue (q,8);
enqueue (q,3);
Push (S,7);
Push (S,9);
for ( i=0;i<5;i++)
{
printf ;
printf ;
enqueue (q,i);
Push (S,i+5)
}
Enqueue (q,8);
enqueue (q,3);
Push (S,7);
Push (S,9);
for ( i=0;i<5;i++)
{
printf ;
printf ;
enqueue (q,i);
Push (S,i+5)
}
Question 6
Choose the true statement.
- 1911 attempts
- 3 upvotes
- 18 comments
Jun 29GATE & PSU CS