Category Archives: Source Code
Autocomplete with trie – Code
Autocomplete is a feature that search box returns the suggestions based on what you have typed. Autocomplete with trie provides an implementation of auto-complete by using data structure trie. A trie is a tree-like data structure in which every node stores a character. After building the trie, strings or substrings …
Huffman coding and decoding – Step by step
By applying huffman algorithms, we compress the input string by using the generated code. We can also use the code to decompress to get the original string. Here are the steps of huffman coding and decoding. The code is available in Java, JavaScript and Python. Amazon Interview Question(modified) Implement the …
Find K closest points to origin – Time complexity explained
Prefix to postfix (2 solutions) – stack and recursion
In mathematics expressions, there are infix, prefix and postfix notations. Infix notation is characterized by the placement of operators between operands. For example, the plus sign in 2 + 2. Prefix notation is a notation in which operators precede their operands, such as + 3 4. Postfix notation is a …
Hierholzer’s algorithm to find Euler path – undirected graph
Web scraping in Java – Jsoup and selenium
Get suggested friends (2 solutions) – DFS and Union Find
Get suggested friends is one of a coding question in social network applications. The data structures for social network is usually a graph. In the graph, you can use depth first search(DFS) or breadth first search(BFS) to find the connections between people. Alternatively, you can also use Union find to …
Shortest path and 2nd shortest path using Dijkstra – code
Dijkstra’s algorithm is an algorithm to find the shortest paths between vertices in a graph. It uses greedy technique by picking the un-visited vertex with the lowest distance. When all vertices have been evaluated, the result is the shortest path. This post provides code to find shortest path and second …