Problem Detail: Suppose we have given a list of 100 numbers. Then How can we calculate the minimum number of comparisons required to find the minimum and the maximum of 100 numbers. Recurrence for the above problem is $$T(n)=T(lceil frac{n}{2} rceil) Read More …
Category: Uncategorized
Confused about proof that $log(n!) = Theta(n log n)$
Problem Detail: So I was able to show that: $log(n!) = O(nlog n)$ without any problems. My question is when trying to prove that $log (n!) = Omega(nlog n)$. I was able to show that: $$begin{align*} log n! &= log(1 cdot Read More …
Why is ‘Manhattan distance’ a better heuristic for 15 puzzle than ‘number of tiles misplaced’?
Problem Detail: Consider two heuristics $h_1$ and $h_2$ defined for the 15 puzzle problem as: $h_1(n)$ = number of misplaced tiles $h_2(n)$ = total Manhatten distance Could anyone tell why $h_2$ is a better heuristic than $h_1$? I would like to Read More …
When are two simulations not a bisimulation?
Problem Detail: Given a labelled transition system $(S,Lambda,to)$, where $S$ is a set of states, $Lambda$ is a set of labels, and $tosubseteq StimesLambdatimes S$ is a ternary relation. As usual, write $p stackrelalpharightarrow q$ for $(p,alpha,q)into$. The labelled transition $pstackrelalphato Read More …
Why is the optimal cut-off for switching from Quicksort to Insertion sort machine dependent?
Problem Detail: I fail to understand why cut off value would be system dependent, and not a constant. From Princeton University website Cutoff to insertion sort. As with mergesort, it pays to switch to insertion sort for tiny arrays. The optimum Read More …
How long does the Collatz recursion run?
Problem Detail: I have the following Python code. def collatz(n): if n <= 1: return True elif (n%2==0): return collatz(n/2) else: return collatz(3*n+1) What is the running-time of this algorithm? Try: If $T(n)$ denotes the running time of the function collatz(n). Read More …
Why can the alphabet be represented in numbers in base 256
Problem Detail: This is in context of hashing of strings. I’m not sure why a string like, CS, could be represented as CS = ‘c’*256 + ‘s’ Does anyone know about this? Asked By : John Swoon Answered By : David Richerby A Read More …
Converting a digraph to an undirected graph in a reversible way
Problem Detail: I am looking for an algorithm to convert a digraph (directed graph) to an undirected graph in a reversible way, ie the digraph should be reconstructable if we are given the undirected graph. I understand that this will come Read More …
Understanding DPLL algorithm
Problem Detail: I’m trying to understand DPLL algorithm for solving SAT problem. And here it is: Algorithm DPLL Input: A set of clauses Φ. Output: A Truth Value. function DPLL(Φ) if Φ is a consistent set of literals then return true; Read More …
Dealing with intractability: NP-complete problems
Problem Detail: Assume that I am a programmer and I have an NP-complete problem that I need to solve it. What methods are available to deal with NPC problems? Is there a survey or something similar on this topic? Asked By Read More …