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 …
Category: Uncategorized
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 …
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 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 …
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 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 …
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 …
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 …
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 …