Red-Black Tree in C#

Red-Black Trees are another self balancing binary search tree data structure.  Much like the AVL Tree which is also self balancing and has the same time complexity O(log n) for best, average & worst case. Red-Black Trees are a bit more efficient in insertion and deletion in that they require less work to be done,…

Heapsort C# Tutorial

Heap Sort is another sorting algorithm that is comparison based and is part of the selection sort group of algorithms. In terms of performance, it has the same O(n * log n) time complexity and is close to being as efficient as the Quick Sort and Merge Sort, however, it is a bit slower. It…

AVL Tree in C#

**Updated as of Nov 2016** AVL Tree is a self balancing binary tree data structure. It has a very efficient Insert, Delete, and Find times. In terms of the depth of an AVL tree on both sides, it differs at most by 1 level. At any other time where difference in height/depth is greater than…

Mergesort C# and C++

Mergesort is another prominent sorting algorithm. Just like Quicksort its a divide and conquer based algorithm. However, unlike Quicksort, Mergesort is stable. Nonetheless, it is also recommended for larger collections. Run time for this algorithm is O(n log n), for best, average, and worst case. In terms of space complexity, Mergesort takes O(n) amount of…

Quicksort in C# and C++

Quicksort is another common sorting algorithm. Its a divide and conquer based algorithm. Quicksort is better to use with bigger collections as the time complexity is better in the long run. For smaller collections its better to use the Bubble Sort or the Insertion Sort. Algorithm explained: Pick a pivot value. In Quicksort, the pivot…