Test 2 - Programming and Data Structure | Computer Science(CS)
Description: GATE Previous year Topic Wise Questions and Answers | Programming and Data Structure | |
Number of Questions: 28 | |
Created by: Aliensbrain Bot | |
Tags: Programming and Data Structures GATE CS |
What is printed by the print statements in the program P1 assuming call by reference parameter passing?
Program P1(){
x = 10;
y = 3;
func1(y, x, x);
print x;
print y;
}
func1(x, y, z) {
y = y + 4;
z = x + y + z;
}
Consider the following declaration of a two-dimensional array in C: Char a[100][100] Assuming that the main memory is byte-addressable and that array is stored starting form memory address 0, the address of a [40] [50] is
The results returned by function under value-result and reference parameter passing conventions
Consider the following three functions:
Which of the above three functions are likely to cause problems with pointers?
The goal of structured programming is to
The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (tree height is the maximum distance of a leaf node from the root)?
Consider the following program Program P2
If the language has dynamic scooping and parameters are passed by reference, what will be printed by the program?
The best data structure to check whether an arithmetic expression has balanced parenthesis is a
Consider the following C function
int f(int n) {
static int i = 1;
if (n >= 5) return n;
n = n + i;
i++;
return f(n);
}
The value returned by f(1) is
A circularly linked list is used to represent a Queue. A single variable p is used to access the Queue. To which node should p point such that both the operations enQueue and deQueue can be performed in constant time?
The elements 32, 15, 20, 30, 12, 25, 16 are inserted one by one in the given order into a max Heap. The resultant max Heap is
Consider the following C program segment:char p[20]; char *s = "string"; int length = strlen(s); int i; for (i = 0; i < length; i++) p[i] = s[length - i]; printf("%s",p);The output of the program is
Consider the following C function void swap (int a, int b) { int temp; temp =a; a =b; b =temp; } In the order to exchange the values of two variables x and y .
Consider the following C program
The program computers
Consider the following program fragment for reversing the digits in a given integer to obtain a new integer.
Let n = d1 d2 ………… dm
int n, rev;
rev = 0;
while (n < 0) {
rev = rev * 10 + n % 10;
n = n / 10;
}
The loop invariant condition at the end of the ith iteration is
What does the following C-statement declare?
What does the following algorithm approximate? (Assume m>1,
A single array A [1........MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top 1 and top 2 (top 1<top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for “stack full” is
An Abstract Data type (ADT) is
Assume that the operators +, -, x are left associative and $\land$ is right associative .The order of precedence (from highest to lowest) is $\land$, x, +, -. The postfix expression corresponding to the infix expression a + b x c - d $\land$ e $\land$ f is
Post order traversal of a given binary search tree, T produces the following sequence of keys 10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29
Which one of the following sequences of keys can be the result of an in order traversal of the tree T?
A common property of logic programming languages and functional languages is
Consider the following C program segment
The value returned by the function Do Something when a pointer to the proof of a non-empty tree is passed as argument is
A program P reads in 500 integers in the range (0, 100) representing the scores of 500 students. It then prints the frequency of each score above 50. What be the best way for P to store the frequencies?
Choose the best matching between the programming styles in Group 1 and their characteristics in Group 2.
Consider the following C-program:
void foo(int n, int sum) {
int k = 0, j = 0;
if (n == 0) return;
k = n % 10;
j = n / 10;
sum = sum + k;
foo(j, sum);
printf("%d,", k);
}
int main() {
int a = 2048, sum = 0;
foo(a, sum);
printf("%dn", sum);
getchar();
}
What does the above program print?
Which of the following are essential features of an object-oriented programming language?
- Abstraction and encapsulation
- Strictly-typedness
- Type-safe property coupled with sub-type rule
- Polymorphism in the presence of inheritance
Consider the following C-program:
double foo(double); /* Line 1 */
int main() {
double da, db;
// input da
db = foo(da);
}
double foo(double a) {
return a;
}
The above code complied without any error or warning. If Line 1 is deleted, the above code will show