Recent questions and answers in Programming and DS

9.3k
views
5 answers
15 votes
Let $H$ be a binary min-heap consisting of $n$ elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the maximum element in ... \Theta (1)$\Theta (\log n)$\Theta (n)$\Theta (n \log n)$
164
views
1 answers
0 votes
let suppose address of first index of array is n and size of each block of array is u. then the index of second element is a+u.let suppose the array has m elements. ... array of same size, if it's address of second last element is (n - u).
91
views
2 answers
1 votes
#include <stdio.h> int main() { // Write C code here int i=10,*p,**q,***r; p=&i; *p=15; q=&p; **q=20; r=&q; ***r=*p+1; printf("%d",i); return 0; }answer the output as integer _________
3.1k
views
3 answers
7 votes
Consider the following $\mathrm{C}$ function definition.int f X(char * a) { char * b = a; while (*b) b ++; return b - a; }Which of the following ... in main (), the function call $\mathrm{fX}(\mathrm{c})$ will always return a value
5.0k
views
3 answers
8 votes
Consider the following $\text{C}$ program. Assume parameters to a function are evaluated from right to left.#include <stdio.h> int g( int p) { printf( ... $ program?$20101020$10202010$20102010$10201020$
53
views
1 answers
0 votes
Find Output of below Code#include<stdio.h>int sum(int n) { n = 3; if (n == 2) return 2; return sum(n-1)*n ;}int main() { printf("%d\n", sum(5) ); return 0}
63
views
1 answers
1 votes
#include <stdio.h> void f(int (*x)(int)); int myfoo(int i); int (*foo)(int) = myfoo; int main() { f(foo(10)); } void f( ... i; }sanfoundry C programming Questiona) Compile time errorb) Undefined behaviourc) 10 11d) 10 Segmentation fault 
97
views
1 answers
1 votes
#include <stdio.h> int main() { int (*a)[2]; int arr[4][4]={1,2,3,4,6,7,8,9}; a=arr; ++a; printf("%d",**a); return 0; }what is the answer NUMARICAL--------------------------------?
57
views
0 answers
1 votes
#include <stdio.h> void f(int (*x)(int)); int mysh(int); int (*sh)() = mysh; int main() { f(sh); sh++; for(int x=sh;x>=0;x--){ if(x){ printf ... A:10C:10 i will go thereB:10 i will go there number of timesD:10 i will go here number of times
40
views
0 answers
0 votes
Not related to gate but genral programming..if some one ask me array indexing start from 0,yes i know array indexing start from 0 . but can i also say ... Array indexing tell me how many steps ahed are from the first position of array,
122
views
1 answers
1 votes
#include <stdio.h> int main () { int i, k; int a [8] = {33,34,35,36,37,40,50,38}; for(i = 0; i < 3; i++) { a[i] = a[i] + 1; i=i+1; } ... int i = k/2; a[i] = a[i] - 1; } printf ("%d",i+a[i]); }Numerical Answer ______________________________
149
views
1 answers
1 votes
what is output of c code : assume answer Is numerical...🙂
83
views
1 answers
1 votes
what is output of this c codeA: 321B: 123C: error(infinite/segmentation)D:333
17.9k
views
6 answers
64 votes
Consider the following program in C language:#include <stdio.h> main() { int i; int*pi = &i; scanf("%d",pi); printf("%d\n", i+5); }Which one of ... of variable $i$.On execution, the value printed is $5$ more than the integer value entered.
26.9k
views
12 answers
57 votes
In a binary tree, the number of internal nodes of degree $1$ is $5$, and the number of internal nodes of degree $2$ is $10$. The number of leaf nodes in the binary tree is$10$11$12$15$
375
views
2 answers
1 votes
Problem Statement: Class teacher to IX-C wants to store whether a particular student has passed in exams. The class has a strength of $32$ students. Their roll ... of set bitsd. Apply Bitwise AND (&) operator and count number of set bits
104
views
1 answers
1 votes
#include <stdio.h> double pom(double x,int n){ if(n==1) return x; else return x*pom(x,n-1); --n; } int main() { int a=pom(2,5); printf("%d",a); return 0; }what is the output of following c codeA:2B:32C:16D:NONE
40.1k
views
7 answers
129 votes
You are given the postorder traversal, $P$, of a binary search tree on the $n$ elements $1, 2, \dots, n$. You have to determine the unique binary search ... n)$\Theta(n\log n)$None of the above, as the tree cannot be uniquely determined
11.9k
views
5 answers
21 votes
The integer value printed by the $\textsf{ANSI-C}$ program given below is _______________#include<stdio.h> int funcp(){ static int x = 1; x++; return x; } int main(){ int x,y; x = funcp(); y = funcp()+x; printf("%d\n", (x+y)); return 0; }
120
views
2 answers
1 votes
answer the output#include <stdio.h> int main() { int x=0; x++; if(--x){ x=x++; if(x){ printf("hello"); }else{ printf("%d",x); } }else{ x=x+5; if(x){ printf("i win x times"); } else{ printf("you win 5 times"); } } return 0; } 
702
views
3 answers
7 votes
What will be the output of following program ?#include <stdio.h> int thefunction(int a) { static int b = 0; b++; a = a + b; return a; } int main() { int b = 0; int i; ... 3; i++) { b = b + thefunction(i); } printf("%d\n", b); return 0; }
5.1k
views
4 answers
20 votes
State whether the following statements are TRUE or FALSE:If the number of leaves in a tree is not a power of $2,$ then the tree is not a binary tree.
29.0k
views
12 answers
77 votes
In a compact single dimensional array representation for lower triangular matrices (i.e all the elements above the diagonal are zero) of size $n \times n$, non-zero elements, (i.e elements of ... $i+\frac{j(j-1)}{2}$
5.3k
views
3 answers
27 votes
The following Pascal program segments finds the largest number in a two-dimensional integer array $A[0\dots n-1, 0\dots n-1]$ using a single loop. Fill up the boxes to complete the ... |C| then j:=j+1; else begin j:=0; i:=|D| end end end
287
views
1 answers
2 votes
Consider the following function:int arc(int i, int j){if(i<2) return j+2;else if(j<2) return arc(i-1, 1);else return arc(i-1, arc(i, j-2));}The value returned by arc(2, 6) is _________
165
views
1 answers
0 votes
Consider the following function:int arc(int i, int j){if(i<2) return j+2;else if(j<2) return arc(i-1, 1);else return arc(i-1, arc(i, j-2));}The value returned by arc(2, 6) is ____________
306
views
1 answers
1 votes
Consider an integer upper triangular 2D array arr[–8 to +7][–8 to +7] having base address 1000. If the size of the integer is 4 bytes, the address of the element present at location arr[–6][4] is- ____________.
4.0k
views
3 answers
6 votes
​​​​​What is the output of the following $\text{C}$ program?#include <stdio.h> int main() { double a[2]=20.0,25.0,* p,* q; p=a ; q=p+1 ; printf("%d,%d", (int) (q-p),( int)(* q- * p)); return 0;$4,8$1,5$8,5$1,8$
9.9k
views
5 answers
21 votes
Consider the problem of reversing a singly linked list. To take an example, given the linked list below,the reversed linked list should look likeWhich one of the following ... is not possible to reverse a singly linked list in $O(1)$ space.
78
views
0 answers
0 votes
146
views
0 answers
0 votes
The array-based stack throws an exception when the array's capacity has been reached. Consider the following alternative : create a larger array, using the resize method. The cost ... the resize, elements maySolutions = O(N^2)O(N)O(N^2)O(N)
17.9k
views
5 answers
67 votes
A scheme for storing binary trees in an array $X$ is as follows. Indexing of $X$ starts at $1$ instead of $0$. the root is stored at $X[1]$. For a node stored at ... $ should be$\log_2 n$n$2n+1$2^n-1$
1.5k
views
1 answers
0 votes
Consider the following left associative operators in decreasing order of precedence :- subtraction (highest precedence)* multiplication ... 4 $ | * 2** 3$-61$64$ $512$ $4096$
312
views
1 answers
1 votes
In which of the following case(s) character array must end with null char?char c[] = "GATE";char c[] = {'2', '0', '2', '3'};char c[4] = "GATE";char c[16] = "2023";
261
views
1 answers
0 votes
#include <stdio.h> int main() { int a[3][2] = {1, 3, 5, 7, 9, 11}; int *ptr = a[0]; ptr += sizeof(int); printf("%d", *ptr); return 0; }(Assume size of int to be $2$ bytes.)The output is __________.
299
views
2 answers
2 votes
What will be printed by following $\text{C}$ code?int a[7] = {0, 1, 2, 3, 4, 5, 6}; int *p = &a[3]; p += 2; *p += 2; printf("%d", *p++);$6$7$8$9$
320
views
2 answers
1 votes
#include<stdio.h>#define ADD(a,b)(a+b)#define SQUARE(x)(x*x)int main(){int x=2;int y=3;int z = ADD(SQUARE(x++),y);printf("%d\n",z);return 0;}What is the output of the above code snippet?
1.1k
views
1 answers
3 votes
Consider a perfect binary tree with $\mathrm{n}$ nodes and $\mathrm{h}$ height. A tree is perfect when all levels of the tree are completely full. ... $S1$ is incorrect but $S2$ is correctBoth are correctBoth are incorrect
647
views
2 answers
1 votes
Five items $\text{A, B, C, D, E}$ are pushed onto a stack, one after other starting from item $\mathrm{A}$. The stack is then popped by three items, and ... . Now, one item is popped from the stack. Which item is at the top of the stack.
To see more, click for all the questions in this category.