Recent questions tagged algorithms

665
views
2 answers
4 votes
Bob writes down a number between 1 and 1,000. Mary must identify that number by asking "yes/no" questions of Bob. Mary knows that Bob always tells the ... that answer at the end of exactly how many questions on the worst case?9995003210
572
views
1 answers
4 votes
Which of the following frequencies for A,B,C and D can generate the following Huffman tree? (Select all that apply.)$p_A=0.4, p_B=0.3, p_C=0.2, p_D=0.1$p_A=0.35, p_B=0.25, ... .25, p_C=0.25, p_D=0.25$p_A=0.2, p_B=0.35, p_C=0.2, p_D=0.25$
705
views
2 answers
2 votes
Consider the following array$: [32, 33, 5, 2, 14, -4, 22, 39, 34, -9].$ We apply a certain sorting algorithm and observe that the ... applied?Merge sort (top-down approach)Bubble sortQuicksort (Using First element as pivot)Insertion sort
509
views
1 answers
5 votes
We have a procedure $P(n)$ that makes multiple calls to a procedure $Q(m)$, and runs in polynomial time in $n$. Unfortunately, a significant flaw was discovered in $Q(m)$ ... time in $n$ if, for each call $Q(m),m \underline<\log \;n.$
169
views
0 answers
0 votes
Consider a directed acyclic graph (DAG) with vertices labeled as P, Q, R, S, T, U, and V. Which of the following sequences represents a possible topological sort of the graph?PRQVSUTPQRSVUTPQRSTUVPRQSVUT
227
views
0 answers
1 votes
Consider the function \(f(n)\), which represents the maximum number of comparisons in binary search on a sorted array of size \(n\). Which of the following recursive ... \left(\lfloor \frac{n}{2} \rfloor\right) + 1\)    None of the above
190
views
0 answers
0 votes
Given the array \( [4, 3, 2, 1, 5] \), which of the following sorting algorithms can successfully sort the array in exactly two passes?Bubble SortInsertion Sort Selection SortMerge Sort
378
views
1 answers
1 votes
Consider the QuickSort algorithm with the last element chosen as the pivot. If the goal is to sort the given array \(a = [30, 40, 50, 60, 70, 80]\) in ascending order, how many swaps will occur during the execution of the algorithm?
283
views
0 answers
0 votes
Consider performing Depth-First Search (DFS) on an undirected and unweighted graph $\bar{G}$ starting at vertex $S$. For any vertex $u$ in $G$, where $d[u]$ ... DFS, the edge $(u, v)$ becomes:A forward edgeA back edgeA cross edgeA tree edge
202
views
0 answers
0 votes
BFS DFS question asking the number of nodes expanded BFS = DFSBFS $ DFSNone
288
views
0 answers
0 votes
Hashing question: Given alpha asking for the expected no of probes.Consider the average time complexity in an unsuccessful search for open-addressing hashing with linear probing. If \( \alpha ... )\( 1 + \alpha \)\(1 + \frac{ \alpha}{2} \)
346
views
1 answers
4 votes
Given that $f(n)=O(g(n))$ (where $\mathrm{O}$ is Big-O) and $f(n)=\Omega(g(n))$, which of the following statement is always true?$f(n)=o(g(n))$ (here $o$ is small-$o).$f(n)=\theta(g(n))$.$f(n)=\omega(g(n))$.Both A and B are always true.
881
views
1 answers
4 votes
Professor Fiorina uses the following algorithm to merge $k$ sorted lists, each containing $n / k$ elements.She takes the first list and merges it with the second list using a ... $\theta(k \log n)$
426
views
1 answers
5 votes
Consider the following weighted graph, where the weight of every edge is written on the edge itself.What is the number of possible minimum spanning trees for the above graph?
819
views
1 answers
11 votes
Consider the following statements related to Huffman's algorithm:$\text{S1:}$ If there is exactly one symbol with a frequency of $1 / 3$, and all other symbols have frequencies ... , but $\mathrm{S} 2$ is true.S1 is false, and S2 is false.
136
views
0 answers
0 votes
1.1k
views
1 answers
11 votes
Consider the two statements regarding the Huffman's algorithm -$\text{S1:}$ The character with the highest probability (all probabilities are unique) is ... $\mathrm{S} 2$ is correctBoth are correct statementsBoth are incorrect statements
598
views
1 answers
3 votes
You are given a bit-array $A[1 \ldots n]$ (i.e., $A[i] \in\{0,1\}$ for each $i$ ) and told that this is a "$0$ -to-$1$ bit-array. This means that ... $\Theta(n \log n)$\Theta(n)$\Theta\left(n^{2}\right)$
716
views
2 answers
5 votes
Consider an array that has $10$ distinct elements. Suppose we use randomized quicksort (with the pivot chosen uniformly at random). What is the probability that the ... of the chosen pivot. The pivot itself is not part of any subarray.
596
views
1 answers
5 votes
Consider the following pseudocode for a function that operates on an $\textsf{N}$ element array $\textsf{A[1],A[2]},\dots,\textsf{A[N]}$ of integers.function ... $\textsf{A[j] < A[position]}$ checked?
1.1k
views
3 answers
3 votes
Of the following, which gives the best upper bound for the value of $f(N)$ where $f$ is a solution to the recurrence$f(2 N+1)=f(2 N)=f(N)+\log N \text { for } N \geq 1,$with $f(1)=0?$O(\log N)$O(N \log N)$O\left((\log N)^2\right)$O(N)$