Check if a binary tree is symmetric or not
Given a binary tree, write an efficient algorithm to check if it has a symmetric structure or not, i.e., left and right subtree mirror each other.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a binary tree, write an efficient algorithm to check if it has a symmetric structure or not, i.e., left and right subtree mirror each other.
Given a binary tree, in-place convert it into its sum tree. Each node’s value is equal to the sum of all elements present in its left and right subtree in a sum tree. Consider the value of an empty node as 0.
Given a binary tree, write an efficient algorithm to print its left view. For example, the left view of the following binary tree is 1, 2, 4, 7.
Given a binary tree, print its nodes level by level in reverse order, i.e., print all nodes present at the last level first, followed by nodes of the second last level, and so on… Print nodes at any level from left to right.
Given a binary tree, print its nodes level by level, i.e., print all nodes of level 1 first, followed by nodes of level 2 and so on… Print nodes for any level from left to right.
Given a binary tree, write an efficient algorithm to delete the entire binary tree. The program should deallocate every single node present in the tree, not just change the root node’s reference to null.
Write an efficient algorithm to compute the binary tree’s height. The height or depth is the total number of edges or nodes on the longest path from the root node to the leaf node.
Write an efficient algorithm to check if two binary trees are identical or not, i.e., if they have identical structure and their contents are also identical.
This post will detect cycles in a linked list using hashing and Floyd’s cycle detection algorithm.
Given a linked list, split it into two lists where each list contains alternating elements from the original list and then finally join them back together.
Given a linked list, move its last node to the front. For example, list {1, 2, 3, 4} should be changed to {4, 1, 2, 3}.
Given a linked list and two positive integers, m and n, delete every n nodes after skipping m nodes.