Majority Element
How to find the majority element in an array
How to count the height of a binary tree
The height of the binary tree is the number of edges in the longest path from the root node to a leaf node.
How to find the minimum depth of a binary tree
How to find the maximum depth of a binary tree
How to find bottom left value in a binary tree
The naive approach, visit all nodes and compare a value in each node. A better approach is to use the definition of a binary search tree.
How to insert a node in a binary search tree
We have seen preorder traversal algorithm for a binary tree without recursion. In this article, we'll implement postorder traversal algorithm for a binary tree without recursion
How to count sum for root to leaf numbers
Given a binary tree, each node has a value from 0 to 9. Each path from a root to a leaf represents a number, return a sum of all these numbers.
How to rotate an array to the right by K steps
Given an array of integers and K, return a rotated array to the right by K steps
How to convert a sorted array to a binary search tree
Given sorted array in ascending order, return a height-balanced binary search tree
Binary tree postorder traversal without recursion
Binary tree maximum path sum
Given a non empty binary tree, find out the path with a maximum sum
Bottom-up level order traversal of a binary tree
Given a binary tree, return the bottom-up level order traversal of a binary tree
Binary tree preorder traversal without recursion
We have seen inorder traversal algorithm for a binary tree without recursion. In this article, we'll implement preorder traversal algorithm for a binary tree without recursion
Binary tree inorder traversal without recursion
We have seen inorder traversal algorithm for a binary tree, but it was a recursive version. In this article, we'll take a look at the non-recursive approach
Lowest common ancestor of a binary search tree
Given a binary search tree and two nodes node1 and node2, return lowest common ancestor value
Path Sum In Binary Tree
Given a binary tree and a sum. Write a method to check if there's a path from a root to a leaf where a sum of nodes equals to the given sum
How to check if a binary tree is a binary search tree
A binary search tree (BST) is a binary tree where each node has a key and meet the following requirements
What is a doubly linked list
A doubly linked list is a linked data structure that consists of a set of sequentially linked nodes.
How to find maximum value in a Binary Search Tree (BST)
How to find minimum value in a Binary Search Tree (BST)
What is a Binary Search Tree
A Binary Search Tree (BST) is a binary tree where each node has a key and meet the following requirements
How to reverse a string
Reverse a string it's a very common question on an interview. During this article, you will know how to do it correctly
What is Breadth First Search
The Breadth First Search (BFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node and explores all of the neighbor nodes at the present present depth before moving on to the nodes at the next depth level.
Graph Data Structure
A graph is a non-linear data structure consisting of nodes and edges. Formally, a graph is a pair of sets (V, E), where V is the set of vertices and E is the set of edges, connecting the pairs of vertices.
How to check if a binary tree is symmetric (recursive approach)
Given a binary tree. Write a method to check does the tree symmetric around the center or not
What is a singly linked list
Singly linked list is a sequence of data structures (nodes), which are connected together through links
What is Depth First Search
The Depth First Search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node and explores all the nodes by going forward if possible or uses backtracking
How to build a queue (linked list implementation)
Queue is a data structure based on first in first out (FIFO) policy
How to check if two binary trees are the same
Given two binary trees, write a method to check if the trees are the same or not
How to invert a binary tree
Given a binary tree. Write a method to invert this tree
Basic data structures every software engineer must know
Data structures every software engineer must know. A data structure is a specialized way of organizing data that allows efficiently process it with associated algorithms.
How to check if a binary tree is symmetric (iterative approach)
Merge two binary trees
Given two binary trees, return a merged tree
Level order traversal of a binary tree
Given a binary tree, return level order traversal
How to calculate the sum of the left leaves of a binary tree
Given a binary tree. Calculate the sum of the left leaves
What is a binary tree
A binary tree is a hierarchical data structure
Binary tree traversals
Traversing a binary tree involves iterating over all nodes in some order
How to count a binary tree size
Given a binary tree, return binary tree size. Size of the binary tree is number of nodes in the tree.
How to build a stack (Linked List implementation)
We already saw how a Stack can be implemented based on an array, now let's take a look at how we can implement the Stack using a linked list
How to build a stack (array implementation)
Stack is a data structure based on last in first out (LIFO) policy
What is a binary search
Binary search is an efficient search algorithm that finds the position of the target value in a sorted array. Let's take a look at an example.