Recent questions tagged algorithms

536
views
2 answers
0 votes
What will be the output printed for find(4)? void find(int x) { static int i = 10, y = 0; y = y + i; for(i; i>0; i = i - 10) { if(x! = 0) find(x – 1); else printf(“%d”, y); } }
452
views
1 answers
2 votes
Let A be an array containing n integers. It is required to find 3 indices i, j, k such that i < j < k and either A[i] ≤ A[j] ≤ A[ ... of the fastest algorithm for this problem, assuming the array is already available, is Θ(_____________).
466
views
1 answers
0 votes
Assume Two-Dimensional Sorted Array (TDSA) is a two-dimensionalmatrix of size n n such as the elements in the matrix are sortedrow-wise and column-wise. For ... of a dimensionn n into TDSA. Analyse the running time of the algorithm.
373
views
0 answers
0 votes
Compute the running time for the following algorithmALGORITHM RKU(a,k,n)//Input: a is an array of n element and k is a value{if( k == n) then{WRITE(a[1:n]);return 0;}else{for i ← k to n ... t;RKU(a, k+1, n);t ← a[k];a[k] ← a[i];a[i] ← t;}}
692
views
1 answers
0 votes
Given ‘N’ objects, which are coloured as red, white and blue. Sort theseobjects so that objects of the same colour are adjacent, with the coloursin the order red, white and blue. Design an algorithm with a time com-plexity of O(nlog n)
551
views
0 answers
0 votes
1. for ( i = 1 ; i <= n ; i++){ for ( j= 1 ; j <= i; j++){ for ( k = 1 ; k <= j ; k++) cout<<"a";}} Here , ... was formed , first term = 1 = 2^0 , last term was 2^n so sum is 2^(n+1) which gives complexity as 2^n)
949
views
1 answers
1 votes
Consider the problem of sorting $n$ single digit integers (base $10$). This problem can be solved in time$O(n \log n)$ but not $O(n \log \log n)$ ... $O(n / \log \log n)$None of the above.
748
views
1 answers
1 votes
Consider the following algorithm for computing the factorial of a positive integer $n$, specified in binary:prod ← 1 for i from 1 to n prod ← prod i output prodAssume ... $\omega\left(n^2\right) $None of the above