Skip to content

Commit

Permalink
Tree information
Browse files Browse the repository at this point in the history
  • Loading branch information
espadrine committed Nov 17, 2015
1 parent 9d01d35 commit 6f3659f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 7 additions & 7 deletions list/Readme.md
Expand Up @@ -3,13 +3,13 @@
Sorted lists are easier to search through / extract data, but maintaining that
property requires either care or full-list sorting (as below).

| | Average | Worst | Stable | Memory |
|-----------|---------------|---------------|--------|-----------------|
|Quicksort | O(n log n) | O(n^2) | no | O(log n) / O(n) |
|Merge sort | O(n log n) | O(n log n) | yes | O(n) |
|" in-place | O(n log(n)^2) | O(n log(n)^2) | yes | O(1) |
|Heapsort | O(n log n) | O(n log n) | no | O(1) |
|Insertion | O(n^2) | O(n^2) | yes | O(1) |
| | Average | Worst | Stable | Memory | Note |
|-----------|---------------|---------------|--------|----------------|--------|
|Merge sort | O(n log n) | O(n log n) | yes | O(n) | |
|" in-place | O(n log(n)^2) | O(n log(n)^2) | yes | O(1) | |
|Quicksort | O(n log n) | O(n^2) | no | O(log n) / O(n)|The pivot technique is used elsewhere|
|Heapsort | O(n log n) | O(n log n) | no | O(1) |In-place|
|Insertion | O(n^2) | O(n^2) | yes | O(1) |Booklike|

## Radix sort

Expand Down
7 changes: 7 additions & 0 deletions tree/Readme.md
Expand Up @@ -54,10 +54,14 @@ If the tree is balanced (= minimal height), we get O(log n) worst-case.
The first self-balanced binary search tree, and the one with the least costly
search. Use this if you only insert during initialization.

Height ≤ `logφ(√5·(n+2))-2`.

### Red-Black tree

Insertions are less costly than an AVL tree.

Height ≤ `2·log2(n+1)`.

### Splay tree

Rarer, it ensures that recently requested searches are faster to search for.
Expand All @@ -69,6 +73,9 @@ Great for priority queues. Efficient to implement as an array.
- Complete binary tree: all levels of the tree must be filled but the bottom.
- Each value stored in a vertex is bigger than or equal to its children.

A nice thing to know: it can sort an array in-place, just by inserting all the
elements into the heap, and extracting the minimum n times.

# B-tree

Achieve O(log(n)) worst-case. Great for IO with large blocks of data: databases,
Expand Down

0 comments on commit 6f3659f

Please sign in to comment.