MSQ1 mark
Let be an odd number greater than 100. Consider a binary minheap with elements stored in an array whose index starts from 1.
Which of the following indices of do/does NOT correspond to any leaf node of the minheap?
One or more correct
GATE CSE previous year questions · Programming & Data Structures
One or more correct
One or more correct
Numerical answer
#include <stdio.h>
void func(int i, int j) {
if(i < j) {
int i = 0;
while (i < 10) {
j += 2;
i++;
}
}
printf("%d", i);
}
int main() {
int i = 9, j = 10;
func(i, j);
return 0;
}
The output of the program is _________. (*answer in integer*)
*Note*: Assume that the program compiles and runs successfully.Numerical answer
struct node{
int elt;
struct node *next;
};
int getListSize (struct node *head)
{
if( E1 ) return 1;
return E2;
}
Which one of the following options gives the correct replacements for the expressions E1 and E2?Single correct
Single correct
int bar(int n){
if (n == 1) return 0;
else return 1 + bar(n/2);
}
int foo(int n){
if (n == 1) return 1;
else return 1 + foo(bar(n));
}
The smallest positive integer n for which foo(n) returns 5 is ______. (*answer in integer*)
*Note:* Ignore syntax errors (if any) in the function.Numerical answer
Numerical answer
T S
I: Inorder L: left subtree, node, right subtree
II: Preorder M: node, left subtree, right subtree
III: Postorder N: left subtree, right subtree, node
Which one of the following is the correct match from T to S?Single correct
#include <stdio.h>
int a=5;
int main(){
int a=7;
return(0);
}
P2
#include <stdio.h>
int main(){
int a=5;
int a=7;
return(0);
}
P3
#include <stdio.h>
int main(){
int a=5;
float a=7;
return(0);
}
Which one of the following statements is true?Single correct
Numerical answer
One or more correct
One or more correct
#include <stdio.h>
int main(){
int *ptr, a, b, c;
a=5; b=11; c=20;
ptr=&a; *ptr=c; ptr=&c;
a=*(&b); c=*ptr-a;
printf("%d",c);
return(0);
}
The output of this program is ____________. (*answer in integer*)
*Note*: Assume that the program compiles and runs successfully.Numerical answer
int func(int start, int end){
int length=end+1-start;
if((length<1)||(start<0)||(end<0)){ return(0); }
if(length%3==0){
return(func(start+1, end));
} else if(length%3==1){
return(1+func(start, end-1));
} else {
return(func(start+2, end));
}
}
The maximum possible value that can be returned from this function is ____________. (*answer in integer*)
*Note*: Ignore syntax errors (if any) in the function.Numerical answer