Question Detail: You are given an array of $2n$ elements $$a_1, a_2, dots, a_n, b_1, b_2, dots b_n$$ The task is to interleave the array, using an in-place algorithm such that the resulting array looks like $$b_1, a_1, b_2, a_2, dots Read More …
Category: Uncategorized
If the speed of electrical charge hasn’t changed, how have computers become faster?
Question Detail: Everyone knows computing speed has drastically increased since their invention, and it looks set to continue. But one thing is puzzling me: if you ran an electrical current through a material today, it would travel at the same speed Read More …
Formalization of the shortest path algorithm to a linear program
Question Detail: I’m trying to understand a formalization of the shortest path algorithm to a linear programming problem: For a graph $G=(E,V)$, we defined $F(v)={e in E mid t(e)=v }$ and $B(v)={ e in E mid h(e)=v}$ where $t(e)$ is a Read More …
Are there any problems that get easier as they increase in size?
Question Detail: This may be a ridiculous question, but is it possible to have a problem that actually gets easier as the inputs grow in size? I doubt any practical problems are like this, but maybe we can invent a degenerate Read More …
Examples of context-free languages with a non-context-free complements
Question Detail: Context-free languages are not closed under complementation. In the lectures we have been given the same argument as here on Wikipedia. But this only shows that one of the three languages $A$, $B$, and $overline A cup overline B$ Read More …
Union of regular languages that is not regular
Question Detail: I’ve come across that question : “Give examples of two regular languages which their union doesn’t output a regular language. “ This is pretty shocking to me because I believe that regular languages are closed under union. Which means Read More …
Solving a recurrence relation with ���n as parameter
Question Detail: Consider the recurrence $qquaddisplaystyle T(n) = sqrt{n} cdot Tbigl(sqrt{n}bigr) + c,n$ for $n gt 2$ with some positive constant $c$, and $T(2) = 1$. I know the Master theorem for solving recurrences, but I’m not sure as to how Read More …
Why is Quicksort described as “in-place” if the sublists take up quite a bit of memory? Surely only something like bubble sort is in-place?
Question Detail: Quicksort is described as “in-place” but using an implementation such as: def sort(array): less = [] equal = [] greater = [] if len(array) > 1: pivot = array[0] for x in array: if x < pivot: less.append(x) if Read More …
Triple nested for-loops
Question Detail: Possible Duplicate: A puzzle related to nested loops I am trying to count the exact/total number of iterations the following nested for-loops are executed: s=0 for (i: 1 to n) for (j: 1 to i) for (k: j Read More …
Triple nested for-loops
Question Detail: Possible Duplicate: A puzzle related to nested loops I am trying to count the exact/total number of iterations the following nested for-loops are executed: s=0 for (i: 1 to n) for (j: 1 to i) for (k: j Read More …