Given a Binary tree, print it in vertical order from left to right.
We could solve this problem by performing a breadth-first or level order traversal on the given tree.
Given a NxN matrix with 0s and 1s. A block with value 1 can be used to travel ahead in the matrix. Now, consider mat[0][0] as the starting point for the rat.
To find the nth fibonacci number, we need not store previous Fibonacci numbers in an array. We could use two temporary variables instead of an array to store previous fibonacci numbers
A sorting algorithm is an algorithm that puts elements of a list into an order. Most frequently we’re required to sort data structures such as arrays, linked lists etc having numerical values. There’re various algorithms to sort a container or a data structure. In this post, we’ll discuss most popular or commonly used algorithms.
In mathematics, Pascal’s triangle is a triangular array of the binomial coefficients. It can also be viewed as: each number in Pascal’s triangle is the sum of the two numbers directly above it.
You are climbing a staircase. It has n steps upto the top. Each time you can either climb 1 step or 2 steps. You’ve to find the number of ways to climb the stair.
Huffman codes are a widely used technique for compressing data. Huffman codes is a greedy algorithm to build up an optimal way of representing each character as a binary string. Suppose we have a 10,000 character data file that we wish to store. And we observe a character ‘a’ occurs very frequently.