Close

Merging k sorted lists

Given K sorted lists, how to merge them into a single sorted list? Let total number of elements in K sorted lists is N. We have to form a single sorted list of length N. For example let us consider the following input lists{4, 19, 27}{1, 6, 50, 73}{9, 45, 59, 67} The output should…

Traversals of a binary tree

Traversal algorithms of non-linear data structures like trees are designed to visit/print all the elements in that structure. There are three main traversals of the binary tree. Namely In-order traversal Post-order traversal Pre-order traversal In addition to these, there are inverses of the above algorithms, and there is a level order traversal. In this post…

Subset sum problem

Given a set of numbers and a target value, we have to find if there is any subset whose sum is equal to the target value. For example let the array be {10, 34, 19, 27, 58, 45} and the target sum is 56, we have a subset {10,19,27} with the given sum. We don’t…

Jolly jumpers problem

In this post I introduce you to a competitive programming problem called Jolly jumpers. This problem is available on UVa online judge on this link.  UVa site is one of the first online judge websites which listed programming problems from different competitions like ACM ICPC and IOI and allowed users to solve and submit their…