Problem Detail: I saw that I can formulate single-source shortest path as the following linear program: Given $G=(V,E)$ and $wcolon Eto R$ and with negative cycles, find $max,d(s,t)$ such that begin{align*} d(s,v) &le d(s,u)+w(u,v) quad forall (u,v)in E d(s,s) &=0 end{align*} Read More …
Category: Uncategorized
[Solved]: Want to know the time complexity inner for loop which is partially iterating the array
Problem Detail: Question: Find out next increasing value of each element in this below array. int[] array = { 5, 2, 7, 10, 4, 12} e.g) 5’s nextIncreasingValue: 7 2’s nextIncreasingValue: 7 7’s nextIncreasingValue: 10 … 12’s nextIncreasingValue: -1 Implementation: for(int Read More …
[Solved]: Expressive power of lexer + parser
Problem Detail: Most modern compilers split their syntax analysis into a lexical phase that is followed by a parsing phase. The lexical phase is given by a regular expression, while parsing is guided by a context-free grammar. What class of languages Read More …
[Solved]: How is IO a monad?
Problem Detail: I am learning the Haskell programming language. From what I am reading, Input/Ouput (IO) raises challenges for Haskell’s purity, since by definition we are interacting with the outside world. From Wikipedia: In a purely functional language, such as Haskell, Read More …
[Solved]: How to prove or disprove that f is computable?
Problem Detail: If $f(x_1,dots, x_n)$ is a total function that for some constant $K$, $f(x_1,dots, x_n) leq K$ for all $x_1,dots, x_n$ then $f$ is computable. I want some hints on how to prove/disprove the above claim. This an exercise from Read More …
[Solved]: Are numbers types and what is “Number”?
Problem Detail: I was pondering about what are the numbers. It seems like a number is data type. I mean, like Maybe in Haskell. Because, for instance, one on its own means nothing for me. However, one apple tells me about Read More …
[Solved]: Quantum algorithms and quantum computation
Problem Detail: Is my (very high-level) understanding correct here regarding quantum algorithms — Quantum computers can process a massive amount of operations in parallel to the nature of qubits and their ability to have states that are superpositions of $|0rangle$ and Read More …
[Solved]: Which problems are hard for P^NP?
Problem Detail: Quantified Boolean formulae are the prime examples of problems that are hard for the polynomial hierarchy, i.e., for the $Pi$ and $Sigma$ versions of it. However, there is also the $Delta$ version, defined as $Delta_{i+1}^{rm P} := {rm P}^{Sigma_i^{rm Read More …
[Solved]: Algorithm analysis in the presence of undefined functions
Problem Detail: I wonder how we can perform algorithm analysis when in an algorithm we have calls of functions whose definition we do not know, e.g. functions delivered by external libraries. Asked By : marekszpak Answered By : David Richerby There are two Read More …
[Solved]: Is summing over all possible $k$-combinations NP-hard?
Problem Detail: Say we have a set of numbers $A={a_1, a_2, dots, a_n}$, and we wish to sum over all possible combinations of $k$ terms to compute $$ sum_{substack{C subseteq {1,2,dots,n} |C|=k}} prod_{c in C} a_c $$ Naively this requires $O(kbinom{n}{k})$ Read More …