Convert Binary to Decimal number

Convert Binary to Decimal number in Java. OR
Write a program to convert Binary to Decimal number in Java.


Given a Binary number, Convert it to Decimal number. Lets see what is the input and expected output.

Check whether Binary Tree is foldable or not.

Given a binary tree, Check if tree can be folded or not?Java Program to Check whether Tree is foldable.


Check whether given binary tree can be folded or not.

Lets see what is the input and expected output for better understanding on Foldable Binary Tree.

check if tree is foldable or not
Check if tree is foldable or not

Print Fibonacci series using Recursive approach in Java

Java Program to Print Fibonacci Series upto K Number.


In this post we will see how to Print Fibonacci series using Recursive approach in Java.
Example: 
Java program to print fibonacci series up to a given number k. 
Input   = 5 Output = 0, 1, 1, 2, 3

Input   = 2
Output = 0, 1

Input   = 7
Output = 0, 1, 1, 2, 3, 5, 8  

Print Fibonacci series using Iterative approach in Java

Java Program to Print Fibonacci Series upto K Number.


In this post we will see how to Print Fibonacci series using Iterative approach in Java.
Example: 
Java program to print fibonacci series up to a given number k. 
Input   = 5 Output = 0, 1, 1, 2, 3

Input   = 2
Output = 0, 1

Input   = 7
Output = 0, 1, 1, 2, 3, 5, 8  

Fibonacci series Iterative and Recursive program in Java

Java Program to print Fibonacci series. OR
Java Program to Print Fibonacci Series upto K Number. OR
Iterative Program to print Fibonacci series. OR
Recursive Program to print Fibonacci series.


What is Fibonacci Series?
Fibonacci series is series of natural number where next number is equivalent to the sum of previous two number.
Example: 
Java program to print fibonacci series up to a given number k. 
Input   = 5 Output = 0, 1, 1, 2, 3

Input   = 2
Output = 0, 1

Input   = 7
Output = 0, 1, 1, 2, 3, 5, 8  

Check if two nodes are cousins in a Binary Tree

Given two nodes in a binary tree, check if they are cousins.


Given the binary Tree and the two nodes say ‘p’ and ‘q’, determine whether the two nodes are cousins of each other or not.

Two nodes are cousins if,

  1. They are not siblings (Children of same parent). 
  2. They are on the same level.
Two nodes are cousins of each other if they are at same level and have different parents.

Lets see few example for better understanding on when two nodes are said to be cousin of each other in Binary Tree.

Find Height of node in Binary tree in Java

Get Height of Node in Binary Tree.


Given a binary tree, Find the height of a given node in Binary tree.

Let's understand what is the input and expected output.

Get Level of node in Binary Tree in Java.

Get Level of node in Binary Tree


Given a binary tree, you need to find level of a given node in the binary tree.

Let's understand what is the input and expected output.

Get Level/Height of node in binary tree

Get Level of node in Binary Tree. OR
Get Height of Node in Binary Tree.


Given a binary tree, you need to find the height of a given node in the tree.
Finding level of node of binary tree is equivalent to finding Height of node of binary tree.

Let's understand what is the input and expected output.