Blogs Hub

by AskGif | Oct 15, 2020 | Category :coding

N-th Tribonacci Number - Recursion - Easy - LeetCode

N-th Tribonacci Number - Recursion - Easy - LeetCode

The Tribonacci sequence Tn is defined as follows:&nbsp; T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n &gt;= 0. Given n, return the value of Tn. &nbsp; Example 1: Input: n = 4<br />Output: 4<br />Explanation:<br />T_3 = 0 + 1 + 1 = 2<br />T_4 = 1 + 1

read more...

by AskGif | Aug 09, 2018 | Category :coding

How to implement PostOrder Traversal in Binary Tree?

How to implement PostOrder Traversal in Binary Tree?

PostOrder Traversal is different from InOrder Traversal and PreOrder Traversal. In this Traversal approach we first traverse through left and then right and at the end, we traverse to the node data. In PostOrder traversal, the root is visited after both subtrees. PostOrder traversal is de

read more...

by AskGif | Aug 09, 2018 | Category :coding

How to implement InOrder Traversal in Binary Tree?

How to implement InOrder Traversal in Binary Tree?

The Technique for traversal in an Inorder is slightly different from what we were doing in PreOrder Traversal. Here we go through left node, then data and then the right node. In an InOrder traversal, the root is visited between the subtrees. InOrder traversal is defined as follows:

read more...

by AskGif | Aug 09, 2018 | Category :coding

How to implement PreOrder Traversal in Binary Tree?

How to implement PreOrder Traversal in Binary Tree?

In pre-order traversal, each node is processed before (pre) either of it's sub-trees. This is the simplest traversal to understand. However, even though each node is processed before the subtrees, it still requires that some information must be maintained while moving down the tree. Preor

read more...

by AskGif | Aug 06, 2018 | Category :coding

Discuss Towers of Hanoi Puzzle.

Discuss Towers of Hanoi Puzzle.

The Tower of Hanoi is a mathematical puzzle.&nbsp; It consists of three rods and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks on one rod in ascending order of size the smallest at the top, thus making a conical shape. The objective of the puz

read more...

by AskGif | Jul 31, 2018 | Category :coding

How to solve Longest Palindromic Subsequence Problem using dynamic programming?

How to solve Longest Palindromic Subsequence Problem using dynamic programming?

The longest palindromic subsequence (LPS) problem is the problem of finding the longest subsequence of a string (a subsequence is obtained by deleting some of the characters from a string without reordering the remaining characters) which is also a palindrome. In general, the longest palindromic

read more...

by AskGif | Jul 31, 2018 | Category :coding

How to solve Edit Distance Problem using dynamic programming?

How to solve Edit Distance Problem using dynamic programming?

In computational linguistics and computer science, edit distance is a way of quantifying how dissimilar two strings (e.g., words) are to one another by counting the minimum number of operations required to transform one string into the other. Edit distances find applications in natural language p

read more...

by AskGif | Jul 31, 2018 | Category :coding

How to Solve Coin Change Problem using Dynamic Programming for Minimum number of ways possible?

How to Solve Coin Change Problem using Dynamic Programming for Minimum number of ways possible?

Coin Change Problem is also known as Making Change Problem. The change-making problem, also known as the minimum coin change problem, addresses the question of finding the minimum number of coins (of certain denominations) that add up to a given amount of money. It is a knapsack type prob

read more...

by AskGif | Jul 31, 2018 | Category :coding

How to solve Knapsack problem using Dynamic Programming

How to solve Knapsack problem using Dynamic Programming

The knapsack problem or rucksack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large a

read more...

by AskGif | Jul 30, 2018 | Category :coding

How to find Nth Number in Catalan Numbers?

How to find Nth Number in Catalan Numbers?

In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. They are named after the Belgian mathematician Eug&egrave;ne Charles Catalan (1814&ndash;1894). The first Catalan numb

read more...

by AskGif | Jul 30, 2018 | Category :coding

How to Find Longest Common Subsequence ?

How to Find Longest Common Subsequence ?

The longest common subsequence (LCS) problem is the problem of finding the longest subsequence common to all sequences in a set of sequences (often just two sequences). It differs from the longest common substring problem: unlike substrings, subsequences are not required to occupy consecutive pos

read more...

by AskGif | Jul 27, 2018 | Category :coding

How to find Nth Number in a Factorial Series?

How to find Nth Number in a Factorial Series?

In mathematics, the factorial of a non-negative integer n, denoted by n! is the product of all positive integers less than or equal to n. For example, The value of 0! is 1, according to the convention for an empty product. The factorial operation is encountered in many areas of ma

read more...