Welcome To Tutorialspoint.dev
Officially launched 18th May 2019

Convert a Binary Tree into its Mirror Tree

Mirror of a Tree: Mirror of a Binary Tree T is another Binary Tree M(T) with left and right children of all non-leaf nodes interchanged. Trees in the above figure a...

Lowest Common Ancestor in a Binary Tree Set 1

Given a binary tree (not a binary search tree) and two values say n1 and n2, write a program to find the least common ancestor. Following is definition of LCA from W...

Write a Program to Find the Maximum Depth or Height of a Tree

Given a binary tree, find height of it. Height of empty tree is 0 and height of below tree is 3. Example Tree Recommended: Please solve it on &#x201C;PRACTICE&#x20...

Diameter of a Binary Tree

The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes. The diagram below shows two trees each with dia...

Diameter of a Binary Tree in O(n) [A new method]

The diameter of a tree is the number of nodes on the longest path between two leaves in the tree. The diagram below shows two trees each with diameter nine, the leave...

Program for n’th node from the end of a Linked List

Given a Linked List and a number n, write a function that returns the value at the n&#x2019;th node from end of the Linked List. For example, if input is below list a...

Function to check if a singly linked list is palindrome

Given a singly linked list of characters, write a function that returns true if the given list is palindrome, else false. Recommended: Please solve it on &#x201C;P...

Print a given matrix in spiral form

Given a 2D array, print it in spiral form. See the following examples. Examples: Input: 1 2 3 4 5 6 7 8 9 10 11 12 ...

Find the number of islands Set 1 (Using DFS)

Given a boolean 2D matrix, find the number of islands. A group of connected 1s forms an island. For example, the below matrix contains 5 islands Example: Input : ma...

Implement Stack using Queues

The problem is opposite of this post. We are given a Queue data structure that supports standard operations like enqueue() and dequeue(). We need to implement a St...