search
Log In

Recent questions and answers in Programming and DS

54 votes
7 answers
1
In a min-heap with $n$ elements with the smallest element at the root, the $7^{th}$ smallest element can be found in time $\Theta (n \log n)$ $\Theta (n)$ $\Theta(\log n)$ $\Theta(1)$
answered 3 days ago in DS rish1602 19.9k views
1 vote
1 answer
2
0 votes
2 answers
3
Main(){ Int a[3][4]={(1,2,3,4),(5,6,7,8),(9,10,11,12)} Print("\n%u%u%u",a[0]+1,*(a[0]+1),*(*(a+0)+1))); } What will be the output if base address is 10.
answered 5 days ago in Programming Pintusaini 542 views
1 vote
2 answers
4
Let $A$ be a square matrix of size $n\times n$. Consider the following program. What is the expected output? C=100 for i=1 to n do for j=1 to n do { Temp=A[i][j]+C A[i][j]=A[j][i] A[j][i]=Temp-C } for i=1 to n do for j=1 to n ... ]); The matrix $A$ itself. Transpose of matrix $A$. Adding $100$ to the upper diagonal elements and subtracting $100$ from diagonal elements of $A$. None of the option.
answered 5 days ago in DS Pintusaini 446 views
1 vote
3 answers
6
1 vote
2 answers
7
4 votes
5 answers
8
2 votes
1 answer
9
What is the output of the following $\text{’C’}$ program? main() { printf(“%x”,-1>>4); } $\text{ffff}$ $\text{0fff}$ $\text{0000}$ $\text{fff0}$
answered Jul 17 in Programming and DS Pintusaini 133 views
3 votes
7 answers
10
32 votes
5 answers
11
Suppose a circular queue of capacity $(n −1)$ elements is implemented with an array of $n$ elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially, $REAR = FRONT = 0$. The conditions to detect queue full and ... $(REAR+1) \mod n == FRONT$ full: $(FRONT+1) \mod n == REAR$ empty: $REAR == FRONT$
answered Jul 16 in DS Aminur0001 14k views
11 votes
7 answers
12
If n has 3, then the statement a[++n]=n++; assigns 3 to a[5] assigns 4 to a[5] assigns 4 to a[4] what is assigned is compiler dependent
answered Jul 15 in Programming Abhishek Chavle 5.1k views
1 vote
1 answer
14
21 votes
6 answers
15
An array $A$ contains $n$ integers in non-decreasing order, $A[1] \leq A[2] \leq \cdots \leq A[n]$. Describe, using Pascal like pseudo code, a linear time algorithm to find $i, j,$ such that $A[i]+A[j]=a$ given integer $M$, if such $i, j$ exist.
answered Jul 8 in DS raja11sep 2.3k views
1 vote
2 answers
16
A priority queue is implemented as a Max-Heap. Initially, it has $5$ elements. The level-order traversal of the heap is: $10,8,5,3,2$. Two new elements $1$ and $7$ are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is $10,8,7,3,2,1,5$ $10,8,7,2,3,1,5$ $10,8,7,1,2,3,5$ $10,8,7,5,3,2,1$
answered Jul 8 in DS rish1602 240 views
70 votes
9 answers
17
A program takes as input a balanced binary search tree with $n$ leaf nodes and computes the value of a function $g(x)$ for each node $x$. If the cost of computing $g(x)$ is: $\Large \min \left ( \substack{\text{number of leaf-nodes}\\\text{in left-subtree of $ ... the worst-case time complexity of the program is? $\Theta (n)$ $\Theta (n \log n)$ $\Theta(n^2)$ $\Theta (n^2\log n)$
answered Jul 2 in DS Abhishek Tank 16.1k views
40 votes
5 answers
18
Suppose there is a balanced binary search tree with $n$ nodes, where at each node, in addition to the key, we store the number of elements in the sub tree rooted at that node. Now, given two elements $a$ and $b$, such that $a < b$, we want to find the ... additions. $O(\log n)$ comparisons but a constant number of additions. $O(n)$ comparisons and $O(n)$ additions, using depth-first- search.
answered Jun 30 in DS Akash 1234Upadhyay 5.1k views
17 votes
7 answers
19
In the worst case, the number of comparisons needed to search a single linked list of length $n$ for a given element is $\log n$ $\frac{n}{2}$ $\log_2 {n} - 1$ $n$
answered Jun 29 in DS Raj sharma07 11k views
1 vote
1 answer
20
can anyone explain by using static and dynamic programing ? what will be output for static and dynamic? #include<stdio.h> int x=10; void part1(int *a) { *a+=x++; printf("%d",*a); } void part2(int *b) { static x=15; *b=*b*x; part1(&x); printf("%d",x); } void main(){ part2(&x); part1(&x); }
answered Jun 26 in Programming bacardi07 296 views
3 votes
4 answers
21
What is the time complexity to delete an arbitrary node from binary heap? O(n) O(log n) O(1) O(n log n)
answered Jun 16 in Programming rish1602 869 views
2 votes
1 answer
22
Output of the following program? #include<stdio.h> struct st { int x; struct st next; }; int main() { struct st temp; temp.x=10; temp.next=temp; printf("%d",temp.next,x); return 0; } Compiler Error $10$ Runtime Error Garbage Value
answered Jun 13 in Programming Anilsapkal 466 views
2 votes
4 answers
23
What is the meaning of following declaration? int(*p[7])(); $p$ is pointer to function $p$ is pointer to such function which return type is array $p$ is array of pointer to function $p$ is pointer to array of function
answered Jun 13 in Programming Anilsapkal 398 views
0 votes
1 answer
24
If space occupied by two strings $s_1$ and $s_2$ in 'C' are respectively $m$ and $n$, then space occupied by string obtained by concatenating $s_1$ and $s_2$ is always less than $m+n$ equal to $m+n$ greater than $m+n$ none of these
answered Jun 13 in Programming Anilsapkal 357 views
0 votes
1 answer
25
HOW CAN WE GET A CROSS EDGE WHILE PERFORMING A BFS ON UNDIRECTED AND DIRECTED GRAPH CAN ANYONE SHOW WITH AN EXAMPLE?
answered Jun 12 in Programming amitgy04 126 views
36 votes
8 answers
26
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 $\text{enQueue}$ and $\text{deQueue}$ can be performed in constant time? rear node front node not possible with a single pointer node next to front
answered Jun 8 in DS Hellosid 19k views
0 votes
2 answers
27
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
answered May 30 in Programming Arjun 1.2k views
44 votes
4 answers
28
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is CORRECT ($n$ refers to the number of items in the queue) ? Both operations can be performed in $O(1)$ time. At most one ... complexity for both operations will be $\Omega (n)$. Worst case time complexity for both operations will be $\Omega (\log n)$
answered May 15 in DS Arjun 13.7k views
21 votes
5 answers
29
Given the programming constructs assignment for loops where the loop parameter cannot be changed within the loop if-then-else forward go to arbitrary go to non-recursive procedure call recursive procedure/function call repeat loop, which constructs will you not include in a programming language such that it should be ... $\text{(vi), (vii), (viii)}$ $\text{(iii), (vii), (viii)}$
answered May 15 in Programming Arjun 4.4k views
0 votes
2 answers
30
The equivalent postfix expression for $d{\large /}(e+f)+b*c$ : $defbc/++*$ $def+/bc+*$ $def+/bc*+$ None of these
answered May 14 in DS Hira Thakur 248 views
0 votes
2 answers
31
0 votes
2 answers
32
Suppose $x$ and $y$ are two Integer Variables having values $0\text{x5AB6}$ and $0\text{x61CD}$ respectively. The result (in hex) of applying bitwise operator and to $x$ and $y$ will be : $0\text{x5089}$ $0\text{x4084}$ $0\text{x78A4}$ $0\text{x3AD1}$
answered May 12 in Programming Hira Thakur 123 views
1 vote
2 answers
33
28 votes
4 answers
34
Let $a$ be an array containing $n$ integers in increasing order. The following algorithm determines whether there are two distinct numbers in the array whose difference is a specified number $S > 0$. i = 0; j = 1; while (j < n ){ if (E) j++; else if (a[j] - a[i] == S) break; else i++; } if (j < n) printf ... expression for E. $a[j] - a[i] > S$ $a[j] - a[i] < S$ $a[i] - a[j] < S$ $a[i] - a[j] > S$
answered May 10 in Programming ASNR1010 4.9k views
47 votes
7 answers
35
In a binary tree, for every node the difference between the number of nodes in the left and right subtrees is at most $2$. If the height of the tree is $h > 0$, then the minimum number of nodes in the tree is $2^{h-1}$ $2^{h-1} + 1$ $2^h - 1$ $2^h$
answered May 10 in DS Jyotish Ranjan 11.5k views
1 vote
2 answers
36
When a user submits a query, a search engine does the following. For every webpage that has been visited by the search engine, it computes a score indicating how relevant that page is to the query. Finally, it reports the pages with the top k scores on the screen, ... by the user. A good data structure for accumulating the scores and ranking them is: a queue a heap a stack a binary search tree
answered May 7 in DS soujanyareddy13 331 views
2 votes
3 answers
37
In the code fragment given below, $\mathsf{start}$ and $\mathsf{end}$ are integer values and $\mathsf{prime(x)}$ is a function that returns $\mathsf{true}$ if $\mathsf{x}$ is a prime number and $\mathsf{false}$ otherwise. i:=0; j:=0; k:=0; from (m := start; m <= end; m := m+1){ if ( ... } } At the end of the loop: $k == i-j.$ $k == j-i.$ $k == -j-i.$ Depends on $\mathsf{start}$ and $\mathsf{end}$
answered May 6 in Programming soujanyareddy13 205 views
1 vote
2 answers
38
Suppose we constructed the binary search tree shown below by starting with an empty tree and inserting one element at a time from an input sequence, without any rotations or other manipulations. Which of the following assertions about the order of elements in the input sequence $cannot$ be true? $8$ ... $1$ came after $12$ and $29$ came before $42$. $3$ came before $14$ and $16$ came before $28$.
answered May 6 in DS soujanyareddy13 285 views
0 votes
2 answers
39
Consider the following functions f() and g(). f(){ g(){ w=5; z=w+1; w=2*z+2; z=3*z-w; } print(z); } We start with $w$ and $z$ set to $0$ and execute $f()$ and $g()$ in parallel—that is, at each step we either execute one statement from $f()$ or one statement from $g()$. Which of the following is not a possible value printed by $g()$ ? $-2$ $-1$ $2$ $4$
answered May 6 in Programming soujanyareddy13 212 views
1 vote
3 answers
40
What does the following function compute in terms of $n$ and $d$, for integer values of $d$ ? Note that the operation $/$ denotes floating point division, even if the arguments are both integers. function foo(n,d){ if (d == 0){ return 1; }else{ if (d < 0){ return foo(n,d+1)/n; }else{ return ... the values of $d$. $n \times d$ if $d>0$ ,$n\div d$ if $d<0$. $n \times d$ for all the values of $d$.
answered May 6 in Programming soujanyareddy13 240 views
To see more, click for all the questions in this category.
...