Implementation of Deque using Doubly Linked List

Problem Statement   The problem “Implementation of Deque using Doubly Linked List” states that you need to implement the following functions of Deque or Doubly Ended Queue using a doubly linked list, insertFront(x) : Add element x at the starting of Deque insertEnd(x) : Add element x at the end of …

Read more

Binary Search Tree Search and Insertion

Problem Statement   Write an algorithm to perform searching and insertion in Binary Search Tree. So what we are going to do is insert some of the elements from input into a binary search tree. Whenever asked to search a particular element, we’ll be searching it among the elements in BST(short …

Read more

Find the smallest positive integer value that cannot be represented as sum of any subset of a given array

Problem Statement   You are given a sorted array of integers. We need to find the smallest positive integer value that cannot be represented as sum of any subset of a given array. Example   arr[] = {1,4,7,8,10} 2 Explanation: Because there is not any sub-array that can represent 2 as a …

Read more

Largest area rectangular sub-matrix with equal number of 1’s and 0’s

Problem Statement   Given a binary matrix of size n x m. The problem is to find the largest area rectangular sub-matrix with equal number of 1’s and 0’s. Example   Dimensions = 4 x 4 Matrix: 1 1 1 1 0 1 0 1 1 0 1 0 1 0 0 …

Read more

Construct BST from its given Level Order Traversal

Given the level order traversal of a Binary Search Tree, write an algorithm to construct the Binary Search Tree or BST from ITS given level order traversal. Example   Input levelOrder[] = {18, 12, 20, 8, 15, 25, 5, 9, 22, 31} Output In-order : 5 8 9 12 15 18 …

Read more