Recent questions tagged algorithms

393
views
1 answers
0 votes
for(i=n, j=0; i>0; i/=2, j+=i)Let val(j) denote the value stored in the variable j after termination of the for loop. Whjch is correct?a. val(j)=theta(logn)b. Val(j)= the...
3.1k
views
2 answers
3 votes
Consider the following array with 7 elements for insertion sort?25, 15, 30, 9, 99, 20, 26 In how many passes, the given sequence will be sorted? (a) 4 pass (b) 5 pass (c)...
596
views
2 answers
1 votes
Consider an interpolation search which is an improvement over binary search where the values in a sorted array are uniformly distributed.In interpolation search construct...
279
views
1 answers
1 votes
Can any one please help me out in understanding how to read :f(n)=O(n^2)I am confused in :1] f(n) is the upper bound of n^22]f(n)’s upper bound is n^2Or is their any a...
2.5k
views
2 answers
0 votes
Consider two strings A = "anandarmy" and B = "algorithms". Let ‘y’ be the length of the longest common subsequence (not necessarily contiguous) between A and B and le...
779
views
1 answers
0 votes
My answer came out to be 13:because when we will compute T(13){as we are using Dynamic programming , it will have to compute value of T(12),T(11),…...T(2) only once(as ...
718
views
0 answers
0 votes
What is the extra memory needed for merge sort:1] In case of Iterative merge sort.(DS:Array)2]In case of Recursive merge sort.(DS:Array)3] In case of Iterative merge sort...
1.6k
views
4 answers
3 votes
Consider a scenario of modified quick sort, where we have given an input sorted array A[1 .. . n], all elements of array are distinct and n >=3. Pivot is the median of se...
335
views
0 answers
0 votes
Which of the following statements is /are FALSE?I.Given a graph where all edge weights are strictly greater than -3, a shortest path between vertices s and t can be found...
1.1k
views
1 answers
1 votes
What is the time complexity of the following recurrence relation and step to derive the same$T(n) = T(\sqrt{n}) + log(logn)$
2.0k
views
0 answers
0 votes
True of FalseBellman ford algorithm correctly computes shortest path in graph with no negative edges /graph can be disconnected as well.
713
views
1 answers
1 votes
The average no. of comparisons performed by the merge sort algorithm, in merging 2 sorted lists of length 2 is___________.Ans: $\frac{8}{3}$
1.1k
views
0 answers
0 votes
Consider the following instance of OBST (Optimal Binary search Tree) problem.N = 4; <$a_1$, $a_2$, $a_3$, $a_4$ = <do, if, int, while>P(1...4) = <3,3,1,1>; Q(0...4) = <2,...
375
views
1 answers
0 votes
When relative ordering of equal keys is preserved after sorting then it is called stable. Quick sort and heap sort is not a stable sorting algorithm . Doubt -IS Select...
741
views
1 answers
1 votes
I am unable to Find its time complexity using Iterative method…Will any one help me out with this .Thank you :)
1.4k
views
1 answers
1 votes
What is the worst case time complexity to count pairs of numbers with difference ‘k’ from an input array of ‘n’ numbers O(log n)O(n log n)O(n)^2O(n^2 log n)The an...
381
views
1 answers
0 votes
I searched on internet but got noting .
676
views
1 answers
2 votes
An unordered list contains n distinct elements. Number of comparisons to find element larger than second minimum isO(1)O(n)None
931
views
1 answers
2 votes
we are given (log m) sorted list each of size (log n) / (log m) the time complexity of merging list into single sorted list using mergesort is equal to a) O ( log m log(l...
534
views
1 answers
1 votes
Assuming $P \neq NP$, Which of the following statements are TRUE?There is no language in $NP$ which has a Deterministic Polynomial time algorithm.There is no language in...
737
views
2 answers
2 votes
Consider the following program code, where pow() is the exponentiation function.f (int n) { if (n <= 1) return 1; return f(n-1) + g(n) + g(pow(2, n-1)); } g (int n) { if ...
630
views
1 answers
1 votes
In a sorted file structure, let the cost of reading a page be $D=10$ milliseconds, the number of data pages be $B=1024$. Let the average time to process a record is $C=5$...
551
views
1 answers
1 votes
Suppose a radix sort was done on the following set of numbers, in binary i.e,$[11, 10, 3, 14, 12, 2, 8, 15, 2]$. How many passes of counting sort would be performed _____...
605
views
1 answers
1 votes
$\text{O}, \Omega,$ and $\Theta$ denote Big-Oh, Big-Omega and Big-Theta notations respectively. Which of the following statement is not correct?$n \: \log a = \Omega (\lo...
1.4k
views
1 answers
1 votes
Insert the following keys in an array of size $17$ using the modulo division method. Use double hashing to resolve collisions. Take $h'(k) = (\text{key%}7)+1$ as the seco...
608
views
1 answers
1 votes
Consider the Knapsack Problem: Given a set of n items, each with a weight $w_i$ and the value $v_i$ determine a subset of items to include in a collection so that the tot...
376
views
0 answers
0 votes
what is the time complexities of the following code snippets. 1.k=1;i=1;while(k<=n){ i++; k=k+i;} 2.for(i=1;i<=n;++i){ for(j=1;j<n;j=j*2) c=c+1;} 3.m=pow(2...