Recent questions tagged go-alogrithms-1

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
782
782 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
954
954 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
966
966 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
881
881 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...
4 4 votes
1 answers 1 answer
694
694 views
Let $T(n)$ denote the number of times the for loop in below code is executed on any input $n$. What can be said about $T(n)$?int iscompute(int n) { for (int i=2;i<=sqrt(n...
2 2 votes
4 answers 4 answers
1.6k
1.6k views
Is an array that is sorted in decreasing order a max-heap?always yesalways nosometimes onlyyes but not in presence of duplicates
4 4 votes
2 answers 2 answers
1.3k
1.3k views
Time complexity of the optimal algorithm to interchange the $m^{th}$ and $n^{th}$ elements of a singly Linked List is $\Theta(m+n)$$\Theta(m)$ when $m\geq n$ otherwise $...
2 2 votes
1 1 answer
1.2k
1.2k views
While inserting keys 12,44,13,88,23,94,11,39,20,16 and 5 in a 11 item hash table using the hash function $h(i) = (2i+5) \mod 11$, total number of collisions that occur ...
2 2 votes
1 answers 1 answer
686
686 views
The Matrix Chain-Product dynamic programming Algorithm runs in _______linear timeexponential timequadratic timecubic time
2 2 votes
1 answers 1 answer
1.4k
1.4k views
A delivery boy at an online e-commerce company is charged with the task of rearranging a number of large crates in order of the time they are to be shipped out. Thus, the...
2 2 votes
1 answers 1 answer
551
551 views
The result of performing an inorder search on the given tree iss y x z v u ty s x z v u ts y v u t z xv u t z x y s
4 4 votes
1 answers 1 answer
1.7k
1.7k views
You are given a 1 billion numbers. The time require in seconds to sort them provided sorting thousand numbers takes 100 microseconds will be _______10,00051230065536
1 1 vote
1 answers 1 answer
819
819 views
Match the following two columns given in a table:1. Randomized quick sorta. $\Theta(n+k)$2. Insertion sortb. $\Theta\left(n^2\right)$3. selection sortc. $\Theta(n)$4. Buc...
3 3 votes
1 answers 1 answer
702
702 views
What is the running time of the following loop? Loop2(n) p < 1 for i < 1 to 2n do p < p*i$\Theta(n^2)$$\Theta(n)$$\Theta(n\lg n)$$\Theta(n^2\lg n)$
2 2 votes
2 answers 2 answers
1.2k
1.2k views
Consider the following recurrence relation.$$T(n) = \begin{cases}1 & \quad if \: n = 1 \\ T(n-1) + 2^n \quad & otherwise \end{cases}$$What will be the value of $T(10)$?
3 3 votes
1 answers 1 answer
1.2k
1.2k views
Let we have 3 steps of an arbitrary program fragment whose running times are $O(n^2), \: O(n^3)$ and $O(n\log n)$, then the running time of whole program is$O(n^3)$$\Omeg...
3 3 votes
2 answers 2 answers
1.3k
1.3k views
Is the following implementation of hashCode() legal assming a hashtable of size 20?public int hashCode(x) { return 17; }yesno because it fills only one slotno because it ...
2 2 votes
1 1 answer
828
828 views
Order the following functions by growth rate :$\log n$$n/\log n$$(3/2)^n$$n\log^2 n$a. $\log n$ $\quad$ b. $n/\log n$ $\quad$ d. $n\log^2 n$ $\quad$ c. $(3/2)^n$ d. $n\...
2 2 votes
1 answers 1 answer
722
722 views
The time complexity of calculating $2^{100}$ isPolynomialExponentialConstantLinear
4 4 votes
5 answers 5 answers
1.8k
1.8k views
If k is a non-negative constant, then the solution to the recurrence$T(n) = \begin{cases} 1 & \quad n=1 \\ 3T(n/2) + n & \quad n>1 \end{cases} $for $n$, a power of 2 is ...
7 7 votes
2 answers 2 answers
4.0k
4.0k views
Consider the following algorithm for searching for a given number $x$ in an unsorted array $A[1...n]$ having $n$ values : Sequentially choose $i$ from 1 to n if A[i] = x ...
9 9 votes
2 answers 2 answers
2.0k
2.0k views
For the following program fragment, the running time is given bysum = 0; for(i = 1; i< n ; i++) for(j = 1; j<i; j++) if(i < j == 0) for(k = 0; k<j; k++) sum++;$\Theta(1)$...
3 3 votes
2 answers 2 answers
1.5k
1.5k views
The best known algorithm for binary to decimal conversion runs in $(n$ is the number of bits in the input number, assume MUL and ADD operations to take constant time)$\Th...
8 8 votes
2 answers 2 answers
2.7k
2.7k views
For the following program fragment, the running time is given byProcedure A(n) { if(n <= 2) return 1; else return A(log (n)); }$\Theta(\log \log n)$$\Theta(\log \sqrt n)$...
To see more, click for the full list of questions or popular tags.