Question Detail: I have been wondering about this question since I was an undergraduate student. It is a general question but I will elaborate with examples below. I have seen a lot of algorithms – for example, for maximum flow problems, Read More …
Blog
How to show that a function is not computable?
Question Detail: I know that there exist a Turing Machine, if a function is computable. Then how to show that the function is not computable or there aren’t any Turing Machine for that. Is there anything like a Pumping lemma? Asked Read More …
What is the most efficient way to compute factorials modulo a prime?
Question Detail: Do you know any algorithm that calculates the factorial after modulus efficiently? For example, I want to program: for(i=0; i<5; i++) sum += factorial(p-i) % p; But, p is a big number (prime) for applying factorial directly $(p leq Read More …
DFA for exactly two of a and one or more of b
Question Detail: I’m totally new to DFA’s and automaton in general — this is the first week or two of class that I’ve actually seen this — and I’m curious as to a pattern to match the following: “Match the set Read More …
Maximum number of nodes with height h
Question Detail: How is $frac{n}{2^{h+1}}$ the maximum possible number of nodes at height $h$ for a binary search tree or heap tree? I saw this as proof to asymptotically bound the build_heap function in the book, but I don’t get it. Read More …
How does the 3-opt algorithm for TSP work?
Question Detail: I understand that the 3-Opt Heuristic for solving the Traveling Salesman problem involves removing three edges from a graph and adding three more to recomplete the tour. However, I’ve seen many papers that mention that when three edges are Read More …
How to fool the “try some test cases” heuristic: Algorithms that appear correct, but are actually incorrect
Question Detail: To try to test whether an algorithm for some problem is correct, the usual starting point is to try running the algorithm by hand on a number of simple test cases — try it on a few example problem Read More …
Left-Factoring a grammar into LL(1)
Question Detail: I have a homework assignment where I need to convert a grammar into LL(1). I’ve already removed the left recursion, but I’m having trouble doing left-factoring. All of the examples I’ve found are simple, and look something like this: Read More …
Finding the minimum cut of an undirected graph
Question Detail: Here’s a question from a past exam I’m trying to solve: For an undirected graph $G$ with positive weights $w(e) geq 0$, I’m trying to find the minimum cut. I don’t know other ways of doing that besides using Read More …
How can I teach computer science without using computers?
Question Detail: In some places in the world, people don’t usually have access to (and hence little knowledge of) computers, and even if they have, hard- and software are outdated and usage plagued by power outages and such. Access to (good) Read More …