search
Log In

Recent questions in Programming and DS

1 vote
1 answer
1
Output of following program? #include<stdio.h> void dynamic(int s,...) { printf("%d",s); } int main() { dynamic(2,4,6,8); dynamic(3,6,9); return 0; } $2\:3$ Compiler Error $4\:3$ $3\:2$
asked Mar 30, 2020 in Programming Lakshman Patel RJIT 229 views
0 votes
2 answers
2
Output of following program? #include<stdio.h> int main() { int *ptr; int x; ptr=&x; *ptr=0; printf("x=%d\n",x); printf("*ptr=%d\n",*ptr); *ptr+=5; printf("x=%d\n",x); printf("*ptr=%d\n",*ptr); (*ptr)++; printf( x=%d\n",x); printf("*ptr=%d\n",*ptr); return 0; } $x=0$ $^*ptr=0$ ... $^*ptr=0$ $x=5$ $^*ptr=5$ $x=$garbage value $^*ptr=$garbage value $x=0$ $^*ptr=0$ $x=0$ $^*ptr=0$ $x=0$ $^*ptr=0$
asked Mar 30, 2020 in Programming Lakshman Patel RJIT 161 views
1 vote
1 answer
3
Assume that float takes $4$ bytes, predict the output of following program. #include<stdio.h> int main() { float arr[5]={12.5,10.0,13.5,90.5,0.5}; float *ptr1=&arr[0]; float *ptr2=ptr1+3; printf("%f",*ptr2); printf("%d",ptr2-ptr1); return 0; } $90.500000\:\:3$ $90.500000\:\:12$ $10.000000\:\:12$ $0.500000\:\:3$
asked Mar 30, 2020 in Programming Lakshman Patel RJIT 344 views
1 vote
1 answer
4
Assume that size of an integer is $32$ bit. What is the output of following ANSI C program? #include<stdio.h> struct st { int x; static int y; }; int main() { printf(%d",sizeof(struct st)); return 0; } $4$ $8$ Compiler Error Runtime Error
asked Mar 30, 2020 in Programming Lakshman Patel RJIT 278 views
1 vote
1 answer
5
Consider the following C declaration struct { short s[5]; union { float y; long z; }u; }t; Assume that objects of the type short, float and long occupy $2$ bytes, $4$ bytes and $8$ bytes respectively. The memory requirement for variable $t$ ignoring alignment considerations, is $22$ bytes $14$ bytes $18$ bytes $10$ bytes
asked Mar 30, 2020 in Programming Lakshman Patel RJIT 170 views
1 vote
1 answer
6
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
asked Mar 30, 2020 in Programming Lakshman Patel RJIT 321 views
3 votes
1 answer
7
What does the following function do for a given Linked List with first node as head? void fun1(struct node* head) { if(head==NULL) return; fun1(head->next); printf("%d",head->data); } Prints all nodes of linked lists Prints all nodes of linked list in reverse order Prints alternate nodes of Linked List Prints alternate nodes in reverse order
asked Mar 30, 2020 in DS Lakshman Patel RJIT 481 views
2 votes
1 answer
8
Consider the following function that takes reference to head of a Doubly Linked List as parameter. Assume that a node of doubly linked list has previous pointer as $\textit{prev}$ and next pointer as $\textit{next}$. void fun(struct node ** ... $6 \leftrightarrow 5 \leftrightarrow 4 \leftrightarrow 3 \leftrightarrow 1 \leftrightarrow 2$
asked Mar 30, 2020 in DS Lakshman Patel RJIT 339 views
1 vote
2 answers
9
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.
asked Mar 30, 2020 in DS Lakshman Patel RJIT 350 views
1 vote
2 answers
10
Following is C like Pseudo code of a function that takes a number as an argument, and uses a stack S to do processing. void fun(int n) { Stack S;//Say it creates an empty stack S while(n>0) { // This line pushes the value of n%2 to stack S; Push(&S,n%2); n=n ... $n$ in reverse order. Prints binary representation of $n$. Prints the value of $\log n$. Prints the value of $\log n$ in reverse order.
asked Mar 30, 2020 in Programming Lakshman Patel RJIT 260 views
0 votes
2 answers
11
Assume that the operators $+,-,\times$ are left associative and $\wedge$ is right associative. The order of precedence(from highest to lowest) is $\wedge,\times, +,-$. The postfix expression corresponding to the infix expression $a+b\times c-d\wedge e\wedge f$ is $abc\times+def\wedge\wedge-$ $abc\times+de\wedge f\wedge-$ $ab+c\times d-e\wedge f\wedge $ $-+a\times bc\wedge\wedge def$
asked Mar 30, 2020 in DS Lakshman Patel RJIT 248 views
1 vote
2 answers
12
A balance factor in AVL tree is used to check what rotation to make if all child nodes are at same level when the last rotation occurred if the tree is unbalanced
asked Mar 30, 2020 in DS Lakshman Patel RJIT 1.2k views
0 votes
2 answers
13
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$
asked Mar 30, 2020 in DS Lakshman Patel RJIT 180 views
0 votes
1 answer
14
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)$.
asked Mar 30, 2020 in DS Lakshman Patel RJIT 249 views
0 votes
3 answers
15
Kadane algorithm is used to find Maximum sum subsequence in an array Maximum sum subarray in an array Maximum product subsequence in an array Maximum product subarray in an array
asked Mar 30, 2020 in DS Lakshman Patel RJIT 267 views
0 votes
1 answer
16
In a complete $k$-ary tree, every internal node has exactly $k$ children. The number of leaves in such a tree with $n$ internal nodes is $nk$ $(n-1)k+1$ $n(k-1)+1$ $n(k-1)$
asked Mar 30, 2020 in DS Lakshman Patel RJIT 236 views
1 vote
4 answers
17
Bug means A logical error in a program A difficult syntax error in a program Documenting programs using an efficient documentation tool All of the above
asked Mar 30, 2020 in Programming Lakshman Patel RJIT 308 views
0 votes
3 answers
18
If for a given Binary Search Tree (BST) the pre-order traversal is $41,23,11,31,62,50,73$. Then which of the following is its post-order traversal? $11,31,23,50,73,62,41$ $31,11,23,50,41,62,73$ $11,31,50,23,73,62,41$ $11,31,23,50,62,73,41$
asked Mar 30, 2020 in DS Lakshman Patel RJIT 535 views
0 votes
2 answers
19
Consider a complete binary tree where the left and the right sub trees of the root are max-heaps. The lower bound for the number of operations to convert the tree to a heap is: $\Omega(\log n)$ $\Omega(n\log n)$ $\Omega(n)$ $\Omega(n^2)$
asked Mar 30, 2020 in DS Lakshman Patel RJIT 324 views
0 votes
2 answers
20
If $x$ is a one dimensional array, then $^*(x+i)$ is same as $^*(\&x[i])$ $\&x[i]$ is same as $x+i-1$ $^*(x+i)$ is same as $^*x[i]$ $^*(x+i)$ is same as $^*x+i$
asked Mar 30, 2020 in Programming Lakshman Patel RJIT 606 views
...