Following is a C++ program that prints 1 to 100 without loop and without recursion.
#include <iostream>
using namespace std;
  
template<...

Share

It is possible to solve this problem using loop or a recursion method. And we have already seen the solution using #define directive (Macro expansion) but what if al...

Share

Recursion : The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called as recursive function…. Read More
...

Share

Write a tail recursive function for calculating the n-th Fibonacci number.
Examples :
Input : n = 4
Output : fib(4) = 3
Input : n = 9
Output : fib(9) = 34
Prerequi...

Share

We have discussed Thread based Morris Traversal. Can we do inorder traversal without threads if we have parent pointers available to us?
Input: Root of Below Tree [E...

Share

Given Preorder traversal of a Binary Search Tree. Then the task is print leaf nodes of the Binary Search Tree from the given preorder.
Examples :
Input : preorder[] =...

Share

Using Stack is the obvious way to traverse tree without recursion. Below is an algorithm for traversing binary tree using stack. See this for step wise step execu...

Share

Using Morris Traversal, we can traverse the tree without using stack and recursion. The idea of Morris Traversal is based on Threaded Binary Tree. In this traversal,...

Share

Prerequisite – Inorder/preorder/postorder traversal of tree
Given a binary tree, perform postorder traversal.
Recommended: Please try your approach on {IDE} ...

Share

Given a binary tree, print all its root to leaf paths without using recursion. For example, consider the following Binary Tree.
6
/
3 5
/ ...

Share