Skip to content

yunus-akbudak/Advanced-Algorithms

 
 

Repository files navigation

Note:

Please don't take effort to create pull requests for new algorithms/data structures. This is just a curiosity driven personal hobby and was originally not intented to be a library. Feel free fork and modify to fit your need if that's what you are looking for. You can however open issues/fix bugs with pull requests here, I would be happy to take a look when I get time. :-)

Advanced Algorithms

Various important computer science algorithms generically implemented in C#.

Build Status

Install by nuget

For beta releases on beta branch

Install-Package Advanced.Algorithms -Pre

Not a stable release yet.

Supports

  • .Net Standard 1.0 or above
  • .Net Framework 4.0 or above

Data Structures

List

Hash Set

Hash Dictionaries

Stack

Queue

Priority Queue

Linked List

Heap

Min

Max

Note: It is observed that among the implementations here in practice, with the exclusion of DecrementKey/IncrementKey operation regular Binary Heap & d-ary Heap outperforms other in theory superiors. Likely because it don't have pointer juggling overhead and hey arrays are faster!

Tree

Binary Search Trees

B Trees (database trees)

Queryable Trees

TODO: Support multi-dimentional segment tree & binary indexed tree.

LookUp Trees

TODO: implement trie compression.

Set

Graph

Adjacency List

Adjacency Matrix

Algorithms

Graph Algorithms

Articulation Points

Bridges

Connectivity

Coloring

Cover

Max Flow

Shortest Path

Matching

  • Max Bipartite Matching (Implementation | Tests) using Edmonds Karp's improved Ford Fulkerson Max Flow algorithm
  • Max Bipartite Matching (Implementation | Tests) using Hopcroft Karp algorithm

Cut

  • Minimum Cut (Implementation | Tests) using Edmonds Karp's improved Ford Fulkerson Max Flow algorithm

Search

Topological Sort

Minimum Spanning Tree

String

Pattern Matching

Compression

Sorting and Searching

  • Binary Search (Implementation | Tests)
  • Quick select for kth smallest/largest in unordered collection using median of medians (Implementation | Tests)
  • Majority element using Moore’s voting algorithm (Implementation | Tests)

Sorting Algorithms

Note: On a decent desktop, in given implementations here for +ive random input integers, the clear winner is counting sort (~0.1 seconds to sort 1 million integers) followed by Radix Sort (~0.4 seconds). Merge Sort, Heap Sort, Quick Sort & Bucket Sort are all winners for +ive & -ive random integer inputs. Tree sort has pointer juggling overhead on backing Red-Black Tree, so performs 8 times slower than Merge Sort in practice. Bubble Sort, Insertion Sort, Selection Sort & Shell Sort are among the worst for random input as observed from results.

Combinatorics

Distributed Systems

  • Circular Queue (Ring Buffer) (Implementation | Tests)
  • Consistant Hash (Implementation | Tests)
  • LRU Cache (Implementation | Tests)
  • Dining philosophers problem (Implementation | Tests)
  • Asynchronous concurrent producer/consumer Bag (Implementation | Tests)
  • Asynchronous concurrent producer/consumer Queue (Implementation | Tests)
  • Asynchronous concurrent producer/consumer Stack (Implementation | Tests)

Numerical Methods

Geometry (in 2D)

Bit Manipulation

About

100+ algorithms & data structures generically implemented in C#

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.3%
  • Other 0.7%