search
Log In

Recent questions in Programming and DS

1 vote
3 answers
1
​​​​​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 $H$? $\Theta (1)$ $\Theta (\log n)$ $\Theta (n)$ $\Theta (n \log n)$
asked Feb 18 in DS Arjun 378 views
0 votes
2 answers
2
Consider the following $\text{ANSI C}$ program. #include <stdio.h> int main( ) { int arr[4][5]; int i, j; for (i=0; i<4; i++) ​​​​​​{ for (j=0; j<5; j++) { arr[i][j] = 10 * i + j; } } printf(“%d”, *(arr[1]+9)); return 0; } What is the output of the above program? $14$ $20$ $24$ $30$
asked Feb 18 in Programming Arjun 412 views
1 vote
2 answers
3
Consider a complete binary tree with $7$ nodes. Let $A$ denote the set of first $3$ elements obtained by performing Breadth-First Search $\text{(BFS)}$ starting from the root. Let $B$ denote the set of first $3$ elements obtained by performing Depth-First Search $\text{(DFS)}$ starting from the root. The value of $\mid A-B \mid $ is _____________
asked Feb 18 in DS Arjun 310 views
1 vote
1 answer
4
Consider the following $\text{ANSI C}$ function: int SomeFunction (int x, int y) { if ((x==1) || (y==1)) return 1; if (x==y) return x; if (x > y) return SomeFunction(x-y, y); if (y > x) return SomeFunction (x, y-x); } The value returned by $\textrm{SomeFunction(15, 255)}$ is __________
asked Feb 18 in Programming Arjun 270 views
0 votes
1 answer
5
Consider the following $\text{ANSI C}$ program: #include <stdio.h> #include <stdlib.h> struct Node{ int value; struct Node *next;}; int main( ) { struct Node *boxE, *head, *boxN; int index=0; boxE=head= (struct Node *) malloc(sizeof(struct Node)) ... $\textsf{return}$ which will be reported as an error by the compiler It dereferences an uninitialized pointer that may result in a run-time error
asked Feb 18 in Programming Arjun 285 views
3 votes
1 answer
6
Consider the following $\text{ANSI C}$ program #include <stdio.h> int foo(int x, int y, int q) { if ((x<=0) && (y<=0)) return q; if (x<=0) return foo(x, y-q, q); if (y<=0) return foo(x-q, y, q); return foo(x, y-q, q) + foo(x-q, y, q); } int main( ) { int r = foo(15, 15, 10); printf(“%d”, r); return 0; } The output of the program upon execution is _________
asked Feb 18 in Programming Arjun 290 views
2 votes
4 answers
7
Let $P$ be an array containing $n$ integers. Let $t$ be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of $n$ elements. Which one of the following choices is correct? $t>2n-2$ ... $t>n \text{ and } t\leq 3\lceil \frac{n}{2}\rceil$ $t>\lceil \log_2(n)\rceil \text{ and } t\leq n$
asked Feb 18 in DS Arjun 454 views
1 vote
1 answer
8
Consider the following statements. $S_1$: The sequence of procedure calls corresponds to a preorder traversal of the activation tree. $S_2$: The sequence of procedure returns corresponds to a postorder traversal of the activation tree. Which one of the following options is correct? $S_1$ is true and ... $S_2$ is true $S_1$ is true and $S_2$ is true $S_1$ is false and $S_2$ is false
asked Feb 18 in DS Arjun 237 views
2 votes
3 answers
9
A binary search tree $T$ contains $n$ distinct elements. What is the time complexity of picking an element in $T$ that is smaller than the maximum element in $T$? $\Theta(n\log n)$ $\Theta(n)$ $\Theta(\log n)$ $\Theta (1)$
asked Feb 18 in DS Arjun 349 views
0 votes
2 answers
10
Consider the following sequence of operations on an empty stack. $\textsf{push}(54);\textsf{push}(52);\textsf{pop}();\textsf{push}(55);\textsf{push}(62);\textsf{s}=\textsf{pop}();$ ... $\textsf{s+q}$ is ___________.
asked Feb 18 in DS Arjun 270 views
0 votes
1 answer
11
Consider the following$\text{ ANSI C}$ program. #include <stdio.h> int main() { int i, j, count; count=0; i=0; for (j=-3; j<=3; j++) { if (( j >= 0) && (i++)) count = count + j; } count = count + ... will compile successfully and output $10$ when executed The program will compile successfully and output $8$ when executed The program will compile successfully and output $13$ when executed
asked Feb 18 in Programming Arjun 209 views
4 votes
2 answers
12
An $articulation$ $point$ in a connected graph is a vertex such that removing the vertex and its incident edges disconnects the graph into two or more connected components. Let $T$ be a $\text{DFS}$ tree obtained by doing $\text{DFS}$ in a connected undirected graph $G$. Which of the following ... and $y$ is a descendent of $u$ in $T$, then all paths from $x$ to $y$ in $G$ must pass through $u$.
asked Feb 18 in DS Arjun 1.6k views
0 votes
1 answer
13
Consider the following $\text{ANSI C}$ function: int SimpleFunction(int Y[], int n, int x) { int total = Y[0], loopIndex; for (loopIndex=1; loopIndex<=n-1; loopIndex++) total=x*total +Y[loopIndex]; return total; } Let $\textsf{Z}$ be an array of $10$ elements with $\textsf{Z}[i]=1$, for all $i$ such that $0 \leq i \leq 9$. The value returned by $\textsf{SimpleFunction(Z},10,2)$ is __________
asked Feb 18 in Programming Arjun 171 views
1 vote
1 answer
14
Consider the following pseudo-code fragment, where $a$ and $b$ are integer variables that have been initialized: /* Pre-conditions : $(a > 1 \wedge a < b)$ */ /* Assume that overflow never occurs */ int $x=0$; int $p=1$; while $(p<b) \{$ $p=p*a$; $x=x+1$; $\}$ ... $\lfloor \: \: \rfloor$ means floor */ $\lfloor \log_a^b \rfloor$ /* $\lceil \: \: \rceil$ means ceil */
asked Nov 20, 2020 in Programming and DS jothee 291 views
2 votes
1 answer
15
Suppose you are compiling on a machine with $1$-byte chars, $2$-byte shorts, $4$-byte ints, and $8$-byte doubles, and with alignment rules that require the address of every primitive data element to be an integer multiple of the element's size. Suppose further that the compiler is not ... ; double r; int i; } A[10]; /*10 element array of structs */ $150$ bytes $320$ bytes $240$ bytes $200$ bytes
asked Nov 20, 2020 in Programming and DS jothee 191 views
0 votes
2 answers
16
A complete $n$-ary tree is a tree in which each node has $n$ children or no children. Let $I$ be the number of internal nodes and $L$ be the number of leaves in a complete $n$-ary tree. If $L=41$, and $I=10$, what is the value of $n$? $3$ $4$ $5$ $6$
asked Nov 20, 2020 in DS jothee 220 views
2 votes
2 answers
17
In a binary max heap containing $n$ numbers, the smallest element can be found in ______ $O(n)$ $O(\log _2 n)$ $O(1)$ $O(\log_2 \log_2 n)$
asked Nov 20, 2020 in DS jothee 143 views
0 votes
1 answer
18
Which of the following statements are true? Minimax search is breadth-first; it processes all the nodes at a level before moving to a node in next level. The effectiveness of the alpha-beta pruning is highly dependent on the order in which the states are examined The alpha-beta search algorithms computes the same ... and $(c)$ only $(a)$ and $(d)$ only $(b)$ and $(c)$ only $(c)$ and $(d)$ only
asked Nov 20, 2020 in DS jothee 96 views
0 votes
1 answer
19
Match $\text{List I}$ with $\text{List II}$ Let $R_1=\{(1,1), (2,2), (3,3)\}$ and $R_2=\{(1,1), (1,2), (1,3), (1,4)\}$ ... answer from the options given below: $A-I, B-II, C-IV, D-III$ $A-I, B-IV, C-III, D-II$ $A-I, B-III, C-II, D-IV$ $A-I, B-IV, C-II, D-III$
asked Nov 20, 2020 in DS jothee 109 views
3 votes
1 answer
20
An external variable is globally accessible by all functions has a declaration “extern” associated with it when declared within a function will be initialized to $0$ if not initialized all of these
asked Apr 2, 2020 in Programming Lakshman Patel RJIT 272 views
...