Category: data structure

Multiply Two Matrix

“Multiply two matrix” is a standard operation which can be applied over two or more matrices. Here, we are given two matrices of dimension r1*c1 and r2*c2 respectively. Our task is to multiply the following matrices and store the result in resultant matrix. CONDITION : The two matrices can only be added if the...

Transpose of a Matrix

“Transpose of a matrix” is a basic problem on matrix where we interchange the row and columns with each other. Here, we are given a matrix of size N*M and our task is to find the transpose of the matrix by interchanging the row and columns. The resultant matrix will...

Merge Overlapping Intervals

“Merge Overlapping Intervals” is a standard application of stack data structure. Here, we have given set of intervals and our task is to merge all overlapping intervals and then print the resultant non-overlapping intervals. Example: The set of intervals are: (1,4) , ( 2,5) , (7,8) , ( 6,9). After merging...

blank

Implement Queue Using Stacks

“Implement Queue using Stacks” is a classic interview problem based on stack and queue data structures. Here, we have given two stacks and our task is to implement queue using these two stack.  Stack contains basically two operations, including:  push and pop. To implement queue using given two stacks, we need to perform some...

blank

Next Greater Element

“Next Greater Element” is a classic interview problem based on stack data structure. Here, we have given an array with ‘n’ elements. Our task is to print next greater element of each element of an array. If there is no greater element for any element in an array, simply print...

blank

Check for balanced parentheses

“Check for balanced parentheses” is one of an ideal application of stack data structure. Here, we have given a parentheses string and our aim is to check whether the given string is balanced parentheses string or not.  Balanced parentheses strings are those strings who have closing parentheses like }, ], ) for each...

blank

Postfix to Prefix Conversion

“Postfix to Prefix Conversion” is a classic example of  stack data structure. Stack can be used to convert given postfix expression to corresponding prefix expression. Operator: Operator are symbols that instruct the computer to perform simple and single tasks. Examples of operators includes + (Addition), – (Subtraction), * (multiplication),… and many...

blank

Postfix to Infix Conversion

“Postfix to Infix conversion” is a classic example of  stack data structure. Stack can be used to convert given postfix expression to corresponding infix expression. Operator: Operator are symbols that instruct the computer to perform simple and single tasks. Examples of operators includes + (Addition), – (Subtraction), * (multiplication),… and many...

blank

Prefix to Postfix Conversion

“Prefix to postfix conversion” is a classic example of  stack data structure. Stack can be used to convert given prefix expression to corresponding postfix expression. Operator: Operator are symbols that instruct the computer to perform simple and single tasks. Examples of operators includes + (Addition), – (Subtraction), * (multiplication),… and many...