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 …
Blog
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 …
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 …
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 …
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 …
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 …
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 …
Memory Consistency vs Cache Coherence
Question Detail: Is it true that Sequential Consistency is a stronger property than Cache Coherence? According to Sorin, Daniel J; Hill, Mark D; Wood, David A: A Primer on Memory Consistency and Cache Coherence, Morgan & Claypool, 2011 sequential consistency can Read More …
Is search a binary heap operation?
Question Detail: According to the Wikipedia page, search is “not an operation” on binary heaps (see complexity box at top-right). Why not? Binary heaps may not be sorted, but they are ordered, and a full graph traversal can find any object Read More …
Nim game tree + minimax
Question Detail: Problem : Two players have in front of them a single pile of objects, say a stack of 7 pennies. The first player divides the original stack into two stacks that must be unequal. Each player alternatively thereafter Read More …