Tag: Algorithm

Kahn’s Topological Sort Algorithm

Given a directed acyclic graph (DAG), print it in Topological order using Kahn’s Topological Sort algorithm. If the DAG has more than one topological ordering, print any of them.

Iterative Merge Sort Algorithm (Bottom-up Merge Sort)

In this post, we will see how to sort an array of integers using iterative merge sort algorithm.     Merge sort is an efficient sorting algorithm which falls under divide and conquer paradigm and produces a stable sort.

Quickselect Algorithm

Quickselect is a selection algorithm to find the kth smallest element in an unordered list. It is closely related to the quicksort sorting algorithm.

Huffman Coding Compression Algorithm

Huffman Coding (also known as Huffman Encoding) is a algorithm for doing data compression and it forms the basic idea behind file compression. This post talks about fixed length and variable length encoding, uniquely decodable codes, prefix rules and construction of Huffman Tree.  

Inorder Tree Traversal | Iterative & Recursive

Given a binary tree, write iterative and recursive solution to traverse the tree using in-order traversal.   Unlike linked lists, one-dimensional arrays and other linear data structures, which are traversed in linear order, trees may be traversed in multiple ways in depth-first order (in-order, pre-order and post-order) or breadth-first order (level order traversal). Beyond these …