# Tag Archives: VMWare

## Merge k sorted arrays | Set 1

Given k sorted arrays of size n each, merge them and print the sorted output. Example: Input: k = 3, n = 4 arr[][] =… Read More »

## Stack | Set 2 (Infix to Postfix)

Prerequisite – Stack | Set 1 (Introduction) Infix expression:The expression of the form a op b. When an operator is in-between every pair of operands.… Read More »

## Find a pair with given sum in a Balanced BST

Given a Balanced Binary Search Tree and a target sum, write a function that returns true if there is a pair with sum equals to… Read More »

## Sieve of Eratosthenes

Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number. Example: Input… Read More »

## Union and Intersection of two Linked Lists

Given two Linked Lists, create union and intersection lists that contain union and intersection of the elements present in the given lists. Order of elements… Read More »

## Sorted Array to Balanced BST

Given a sorted array. Write a function that creates a Balanced Binary Search Tree using array elements. Examples: Input: Array {1, 2, 3} Output: A… Read More »

## A Boolean Matrix Question

Given a boolean matrix mat[M][N] of size M X N, modify it such that if a matrix cell mat[i][j] is 1 (or true) then make… Read More »

## Design and Implement Special Stack Data Structure | Added Space Optimized Version

Question: Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return… Read More »

## Detect and Remove Loop in a Linked List

Write a function detectAndRemoveLoop() that checks whether a given Linked List contains loop and if loop is present then removes the loop and returns true.… Read More »

## Reverse a Linked List in groups of given size | Set 1

Given a linked list, write a function to reverse every k nodes (where k is an input to the function). Example: Input: 1->2->3->4->5->6->7->8->NULL, K =… Read More »

## Maximum width of a binary tree

Given a binary tree, write a function to get the maximum width of the given tree. Width of a tree is maximum of widths of… Read More »

## Run Length Encoding

Given an input string, write a function that returns the Run Length Encoded string for the input string.For example, if the input string is “wwwwaaadexxxxxx”,… Read More »

## Diameter of a Binary Tree

The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes. The diagram below… Read More »

## A program to check if a binary tree is BST or not

A binary search tree (BST) is a node based binary tree data structure which has the following properties. • The left subtree of a node… Read More »

## Write a program to reverse an array or string

Given an array (or string), the task is to reverse the array/string.Examples :   Input : arr[] = {1, 2, 3} Output : arr[] =… Read More »