Write an efficient algorithm to check if two binary trees are identical or not. i.e. if they have identical structure & their contents are also same. The idea is to traverse both trees and compare value at their root node. If the value matches, we recursively check if left subtree of first tree …
Given a line of text, reverse the text without reversing the individual words.
Given a binary pattern that contains ‘?’ wildcard character at few positions, find all possible combinations of binary strings that can be formed by replacing the wildcard character by either 0 or 1.
Write iterative version of recursive Quicksort algorithm.
A stack is a linear data structure which follows the LIFO (last-in first-out) principle. That means the objects can be inserted or removed only at one end of it also called as top.
In previous post, we have discussed C++ implementation of stack data structure using classes. In this article, we will make code generic for all data-types by using C++ templates.
Write code to efficiently evaluate given postfix expression.
Given an balanced expression that can contain opening and closing parenthesis, check if the expression contains any duplicate parenthesis or not.
Given an string containing opening and closing braces, check if it represents a balanced expression or not.
A stack is a linear data structure that serves as a container of objects that are inserted and removed according to the LIFO (last-in first-out) rule.
A stack is an linear data structure that serves as a collection of elements, with three main operations: push, pop and peek. We have discussed about these operations in previous post and covered array implementation of stack data structure. In this post, linked list implementation of stack is covered.
A stack is a linear data structure that serves as a collection of elements, with three main operations: