Find k’th smallest node in a BST
Given a BST and a positive number k, find the k’th smallest node in it.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a BST and a positive number k, find the k’th smallest node in it.
Given a graph, determine if it is bipartite using DFS. A bipartite graph (or bigraph) is a graph whose vertices can be divided into two disjoint sets U and V such that every edge connects a vertex in U to one in V.
Convert a given binary tree into a BST (Binary Search Tree) by keeping its original structure intact.
Given a normal binary tree, convert it into a Left–child right–sibling (LC–RS) binary tree. Each node in the LC–RS binary tree has two pointers: one to the node’s left child and one to its next sibling in the original binary tree.
Write an efficient algorithm to print the two-dimensional view of a binary tree.
Write an algorithm to compute a binary tree’s height with leaf nodes forming a circular doubly linked list where the leaf node’s left and right pointers will act as a previous and next pointer of the circular doubly linked list, respectively.
Given a directed graph, check if it is strongly connected or not. A directed graph is said to be strongly connected if every vertex is reachable from every other vertex.
Given a binary tree, write an efficient algorithm to check if a tree is height-balanced or not. In a height-balanced tree, the absolute difference between the height of the left and right subtree for every node is 0 or 1.
Given a huge set of words with duplicates present and a positive integer k, find the first k–maximum occurring words in it.
Lexicographic sorting: Given a set of strings, print them in lexicographic order (dictionary/alphabetical order).
Given a huge set of words with duplicates present, find the maximum occurring word in it. If two words have the same count, return any one of them.
Given an M × N boggle board, find a list of all possible words that can be formed by a sequence of adjacent characters on the board.