Problem Detail: The algorithm is in Python. Seems correct to me, ideas how to prove it? And what would be its time complexity? from bisect import bisect # Implements the decision version of subset sum. # The subset sum problem: given Read More …
Blog
[Solved]: Greedy proof: Correctness versus optimality
Problem Detail: I am really confused after surveying a bunch of material online about correctness versus optimality proof for greedy algorithms. Some website even uses both correctness and optimal in the same sentence! From my best unconfirmed understanding, the optimal proof Read More …
[Solved]: Why is NP in EXPTIME?
Problem Detail: Is there an easy way to see why NP is in EXPTIME? It seems to me a priori conceivable that there could be a problem which requires super-exponential time to solve, but whose solution could be verified in polynomial Read More …
[Solved]: Analysis of very simple algorithm
Problem Detail: I need to find the time complexity of the following simple algorithm. Calculate the time complexity of the following algorithm: void f(int n) { int i, x; for (i = 1; i <= n; i++) if (i % 2 Read More …
[Solved]: What linked list data structure adjustments would give me fast random lookup?
Problem Detail: I am presently using an doubly linked list (C++ std::list) to hold a bunch of records that each have a unique integer identifier. The linked list is created in sorted order such that in the list, the next item Read More …
[Solved]: Graph Theory Handshaking problem
Problem Detail: Mr. and Mrs. Smith, a married couple, invited 9 other married couples to a party. (So the party consisted of 10 couples.) There was a round of handshaking, but no one shook hand with his or her spouse. Afterwards, Read More …
[Solved]: How should I design a hash table where all the keys are permutations?
Problem Detail: I need to create a hash table to store values for (possibly all) permutations of 123456789, which is exactly 362 880 keys. Given that I know how all the keys look up front, it seems I that there should Read More …
[Solved]: Filling Rows of a Matrix Subject to Conditions
Problem Detail: I’m seeking to write an algorithm which, given a value of N, will fill a matrix consisting of (N+1)(N+2)(N+3)/6 rows and 4 columns with the integers from 0, … , N, subject to the conditions that: The sum of Read More …
[Solved]: Solving the recurrence relation $T(n) = 2T(lfloor n/2 rfloor) + n$
Problem Detail: Solving the recurrence relation $T(n) = 2T(lfloor n/2 rfloor) + n$. The book from which this example is, falsely claims that $T(n) = O(n)$ by guessing $T(n) leq cn$ and then arguing $qquad begin{align*} T(n) & leq 2(c lfloor Read More …
[Solved]: How good are current AI researchers at simulating complex, first-person emotional states?
Problem Detail: I just read that IBM’s Watson would have a hard time answering questions like “tell me about your first kiss.” If you asked a modern, state-of-the-art chatbot questions like “tell me about a song that means a lot to Read More …