pitukg / algorithms

Demonstration of some algorithms and data structures.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

algorithms

Demonstration of some algorithms and data structures. This also aims to demonstrate Java and Test Driven Development skills.

B-Tree

This is an implementation of a balanced tree data structure, especially suitable for distributed applications, where different parts of the data structure can reside on different computers, possibly on the other side of the Earth. This is because B-nodes can be stored on different computers and for large t the tree is shallow but lookups, inserts and deletes are still efficient. For t = 1000 one billion entries can be indexed by only 4 lookups.

The special case of t = 2 is also called the 2-3-4 tree which is isomorphic to the popular Red-Black tree.

Fibonacci heap

This data structure has been primarily developed for implementing the priority queue in Dijkstra's algorithms. There are three key operations:

  • insert: called V times in Dijkstra, inserting each vertex into the priority queue, has both true and amortized O(1) cost.
  • decreaseKey: called at most E times in Dijkstra, every time an edge is "relaxed", has amortized O(1) cost
  • popMin: called V times in Dijkstra in each iteration, this is where the cleanup happens, merging the heaps which is particularly efficient in batches, it has amortized O(log n) cost, where the heap contains n elements

These amortized costs can be shown using the potential function Φ = # heaps in root list + 2 * # marked/loser nodes. So this provides an implementation of Dijkstra's algorithms with O(V log V + E) complexity.

About

Demonstration of some algorithms and data structures.


Languages

Language:Java 100.0%