Sorting using trivial hash function

The problem “Sorting using trivial hash function” states that you are given an integer array. An array can be containing both negative and positive numbers. The problem statement asks to sort the array using Trivial Hash Function. Example arr[] = {5,2,1,3,6} {1, 2, 3, 5, 6} arr[] = {-3, -1, …

Read moreSorting using trivial hash function

Find duplicates in a given array when elements are not limited to a range

The problem “Find duplicates in a given array when elements are not limited to a range” states that you have an array consisting of n integers. The problem statement it to find out the duplicate elements if present in the array. If no such element exists return -1. Example [ …

Read moreFind duplicates in a given array when elements are not limited to a range

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 moreImplementation of Deque using Doubly Linked List

K’th Largest Element in BST when modification to BST is not allowed

Problem Statement “K’th Largest Element in BST when modification to BST is not allowed” states that you are given a binary search tree and you need to find the kth largest element. This means that when all the elements of the binary search tree are arranged in descending order. Then …

Read moreK’th Largest Element in BST when modification to BST is not allowed

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 moreBinary Search Tree Search and Insertion

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 moreFind the smallest positive integer value that cannot be represented as sum of any subset of a given array

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 moreLargest area rectangular sub-matrix with equal number of 1’s and 0’s

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 moreConstruct BST from its given Level Order Traversal