Recent questions tagged two-marks

5 5 votes
4 answers 4 answers
2.7k
2.7k views
What will be returned by the following function foo when called as foo(10)?int foo(int n) { return n & n | 1; }
8 8 votes
2 answers 2 answers
1.8k
1.8k views
What will be the outout of the following code?#include <stdio.h int main() { int a = 1, b = 2; int c = a++ || b++; printf("%d %d %d", a, b, c); }1 2 12 3 12 2 12 2 0
5 5 votes
2 answers 2 answers
1.6k
1.6k views
What will be the output of the following program?#include <stdio.h void f1(int p1, int *p2, int p3) { p1 = 20; *p2 = p1; p3 = *p2; p1 = 10; } int main() { int a = 5, b ...
4 4 votes
2 answers 2 answers
2.4k
2.4k views
No. of times '*' will be printed by the following C code is _____#include<stdio.h void foo(int x) { switch(x){ case 1: printf("*"); case 2: printf("*"); case 3: printf("*...
6 6 votes
2 answers 2 answers
1.3k
1.3k views
What is the output of this program?#include <stdio.h int main() { char *ptr; char string[] = "Hello 2017"; ptr = string; ptr += 4; printf("%s",++ptr); }Hello 2017ello 201...
11 11 votes
2 answers 2 answers
2.1k
2.1k views
The output for the following C program will be#include <stdio.h int temp; int new(int t) { static int cal; cal = cal + t; return(cal); } int main() { int t, p; for(t=0; t...
7 7 votes
4 answers 4 answers
3.6k
3.6k views
The output of the following C program will be _____#include<stdio.h #define type int type foo(type b) { return b*b; } #undef type #define type float int main() { float a ...
5 5 votes
3 answers 3 answers
4.6k
4.6k views
Consider the following C functions:int f1(int a, int b) { while (a != b) { if(a b) a = a - b; else b = b - a; } return a; } int f2(int a, int b) { while (b != 0) { int t...
9 9 votes
2 2 answers
2.8k
2.8k views
Consider the following C function:void foo() { int a[10][20][30] = {0}; __________ printf("%d", a[3][4][5]); }Which of the following could be used in the missing line so ...
5 5 votes
2 answers 2 answers
2.8k
2.8k views
What will be the output of the following C program?#include <stdio.h int main() { int f1(int,int); int x = 9,n = 3; printf("%d", f1(x, n)); } int f1(int x, int n) { int y...
1 1 vote
2 2 answers
1.8k
1.8k views
Which of the following is false?Arrays are better than linked lists for sorting due to better data locality.Asymptotic time complxity for FindMax is same on an unsorted a...
5 5 votes
1 answers 1 answer
2.2k
2.2k views
Consider a stack with 100 elements present. Suppose in a scenario, we are required to remove the first inserted element in it, which is done by POP operations followed by...
1 1 vote
2 2 answers
939
939 views
Consider the following nested representation of Binary Trees.$(ABC)$ indicates $B$ and $C$ are left and right subtrees of node $A$ respectively. Note that $B$ and $C$ may...
5 5 votes
3 answers 3 answers
2.6k
2.6k views
You are given a linked list, $L$ of $n$ integers, and another linked list, $P$, of $k$ integers where $k <<< n$. $L$ is sorted in ascending order but $P$ is not necessari...
0 0 votes
2 answers 2 answers
948
948 views
Consider the following declaration of a two dimensional array in C:char a[1000][40];Assuming that the main memory is byte addressable and that the array is stored startin...
2 2 votes
2 answers 2 answers
1.4k
1.4k views
A function $f$ defined on stack of integer satisfies the following properties:$f(\{\}) = 1$ and$f(PUSH(S,i)) = \max (f(S),1) * i$ for all stacks $S$ and integer $i$.If a ...
3 3 votes
1 answers 1 answer
939
939 views
The maximum number of possible edges in an undirected simple graph with $100$ vertices and $5$ components is ___
6 6 votes
1 answers 1 answer
1.3k
1.3k views
When searching for the key value 30 in a binary search tree, nodes containing the key values 10, 20, 25, 35, 70, 80, 90, 100 are traversed, not necessarily in the order g...
5 5 votes
4 answers 4 answers
2.2k
2.2k views
A stack is used to implement a priority queue where $ENQUEUE(Q, x, p)$ ($p$ denotes priority, higher the better) and $DEQUE(Q)$ are implemented by appropriate PUSH and PO...
2 2 votes
1 answers 1 answer
1.0k
1.0k views
The following C function takes a singly-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing th...
2 2 votes
2 2 answers
1.0k
1.0k views
Match the following: i.BFSa.$O(\mid E \mid + \mid V \mid \log \mid V \mid)$ii.DFSb.$O(E)$iii.Kruskal's algorithmc.Stackiv.Dijikstra's Algorithmd.$O(E \log V)$i - b, ii - ...
2 2 votes
3 answers 3 answers
786
786 views
$$T(n) = \begin{cases} 4 & \quad if \: \: n =1 \\ T(n-1) + 4 & \quad otherwise \end{cases}$$Value of $T(1000)$ is ___
2 2 votes
1 answers 1 answer
959
959 views
Match the following i.Dijkstra's Algorithma.All pairs shortest pathii.Bellman Ford Algorithmb.Greedyiii.Floyd-Warshall Algorithmc.Reweightingiv.Johnson Algorithmd.Single ...
1 1 vote
2 answers 2 answers
1.6k
1.6k views
Consider a hash table of size $m = 10$ and a corresponding hash function $h(k) = k A \mod m$ for $A = 5$ where collisions are resolved by quadratic probing. The location...
4 4 votes
1 answers 1 answer
970
970 views
Maximum element in a min-heap represented by an array, can be computed in _____ time$O(n)$$O(\log n)$$O(n \log n)$ but not $O(n)$$O(1)$
3 3 votes
2 2 answers
1.0k
1.0k views
Which of the below options is TRUE for this statement :Suppose we wish to repeatedly search a linked list of length N elements, each of which contains a very long string ...
2 2 votes
1 1 answer
884
884 views
Let you have an array $S[1 \dots n]$ and a function $reverse(s,i,j)$ which reverse the order of elements in $s$ between $i,j$-th positions. What does the following seque...
2 2 votes
2 answers 2 answers
1.4k
1.4k views
About how many compares will Quicksort() make when sorting an array of N items that are all equal?$\Theta(\lg N)$$\Theta(N\lg N)$$\Theta(\lg \lg N)$$\Theta(N/\lg N)$
3 3 votes
2 answers 2 answers
2.5k
2.5k views
Consider the below statements:Adding a constant to every edge weight does not change the solution to the single-source shortest-paths problem.Adding a constant to every e...
4 4 votes
2 answers 2 answers
1.2k
1.2k views
A spell-checker software reads an input file and prints out all words not in some online dictionary. Suppose the dictionary contains 10,000 words and the file has one mil...