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.
You are given an array of non-negative integers, you have to find the number of subsets having sum equal to the given sum. Subset needs not to be contiguous.