News for hackers. Stuff that matters.
Re:Big-O Algorithm Complexity Cheat Sheet by mixedbit on Saturday May 04, 2013 @12:57PM (#5655446)
Agree, buy a good book (for example Cormen), learn the algorithms and implement them to get a good understanding.

Try to use the table to answer a following question: what is a time complexity for finding a next item (according to a key) to a given one in a hash table? Memorizing such stuff does not make much sense, but if you understand basic concepts, you will figure it out quickly.

There are basic errors in the table:

BFS, DFS are for graphs, not just trees, and their complexity is not b^d (what is b and d anyway?).

Quick sort expected complexity is nlogn and this is different than average complexity. You can also make quicksort worst-case complexity to be nlogn.

You can't sort anything with space smaller than number of items you are sorting.

You can use buble and insertion sort not only for arrays but also for lists and time complexity does not suffer.

Re:Big-O Algorithm Complexity Cheat Sheet by paulolc on Saturday May 04, 2013 @05:24PM (#5656365)
You can contribute and fix the table yourself :). The author welcomes it . https://github.com/ericdrowell/BigOCheatSheet/blob/master/Ta...
Re:Big-O Algorithm Complexity Cheat Sheet by sbov on Saturday May 04, 2013 @02:11PM (#5655729)
> You can't sort anything with space smaller than number of items you are sorting.

I assume it's referring to extra space used. Most analysis of space I've seen is referring to this, not the space required to store the elements.

Re:Big-O Algorithm Complexity Cheat Sheet by devcpp on Saturday May 04, 2013 @02:15PM (#5655754)
>what is b and d anyway?

Breadth and depth. These could apply to graphs as well, since these algorithms draw a tree while traversing the graph.

Re:Big-O Algorithm Complexity Cheat Sheet by voltagex_ on Monday May 06, 2013 @01:53AM (#5661081)
$81 for http://www.amazon.com/Introduction-Algorithms-Thomas-H-Corme...

No legal DRM free option as far as I can see.

Fifth link was a direct to the PDF.

Re:Big-O Algorithm Complexity Cheat Sheet by popol on Sunday May 05, 2013 @12:20AM (#5657440)
> BFS, DFS are for graphs, not just trees BFS and DFS are applied to graphs, but the search space is indeed a tree.
Re:Big-O Algorithm Complexity Cheat Sheet by glass_of_water on Saturday May 04, 2013 @02:19PM (#5655769)
Yeah BFS/DFS are O(n) for graphs and trees.
Re:Big-O Algorithm Complexity Cheat Sheet by rttlesnke on Saturday May 04, 2013 @03:12PM (#5655978)
> You can also make quicksort worst-case complexity to be nlogn.

Quicksort in the worst take can take O(n^2) time, not O(nlogn).

Re:Big-O Algorithm Complexity Cheat Sheet by amalcon on Saturday May 04, 2013 @03:23PM (#5656021)
If one takes the time to select optimal pivots it becomes O(nlogn). The selection is free from a big-O perspective, because it's O(n) immediately before the O(n) list division step.

Of course, nobody does this, because the selection is not really free. The constant factor cost of choosing the optimal pivot hurts the average case, making the modified quicksort tend to do worse than heapsort or introsort.

Re:Big-O Algorithm Complexity Cheat Sheet by gamegoblin on Saturday May 04, 2013 @06:11PM (#5656483)
You can use a randomized selection algorithm to find the median in linear time, and if you use the median as a pivot you will never get worst case n^2 behavior.

This is not used in practice because the probability of getting worst case behavior is extremely slim if you do some clever, and cheap, tricks.

Re:Big-O Algorithm Complexity Cheat Sheet by kolistivra on Sunday May 05, 2013 @01:04PM (#5659005)
Randomized selection algoritm is actually O(N^2) in the worst case. Median of medians is the O(N) worst case selection algorithm.
Re:Big-O Algorithm Complexity Cheat Sheet by derleth on Saturday May 04, 2013 @01:49PM (#5655646)
> what is a time complexity for finding a next item (according to a key) to a given one in a hash table?

Problem ill-stated as posed: Does not specify if the 'next' key is hashed, or even what 'next' means in this context.

Re:Big-O Algorithm Complexity Cheat Sheet by mixedbit on Saturday May 04, 2013 @02:05PM (#5655704)
Say, the smallest item in a hash table for which item.key is larger than given_item.key. Assume larger-than relation for keys is defined, so for example keys are integeters.
Re:Big-O Algorithm Complexity Cheat Sheet by sillysaurus on Saturday May 04, 2013 @02:11PM (#5655731)
Say, the smallest item in a hash table for which item.key is larger than given_item.key.

Well, keys in a hash table are hashed. This implies that unless you're searching for a specific key (e.g. "42") rather than a condition (e.g. "smallest key greater than 42") then the time complexity is necessarily O(N).

Re:Big-O Algorithm Complexity Cheat Sheet by mixedbit on Saturday May 04, 2013 @02:34PM (#5655833)
Correct :)