# Tagged: Intermediate

## Breadth-First Search in Disconnected Graph

Objective: Given a disconnected graph, Write a program to do the BFS, Breadth-First Search or traversal. Example: Approach: Earlier we had seen the BFS for a connected graph. In this article, we will extend...

## ZigZag OR Diagonal traversal in 2d array/Matrix using queue

Objective: Given a two-dimensional array or matrix, Write an algorithm to print the given matrix in a zigzag manner or in other words print all the diagonals of the matrix. Example: int [][] grid...

## Evaluation of Prefix Expressions (Reverse Polish Notation) | Set 1

Prefix notation is a notation for writing arithmetic expressions in which the operands appear after their operators. There are no precedence rules to learn. Let’s assume the below Operands are real numbers in real...

## Minimum Boats Required to rescue people

Objective: Given N people need to be rescued by crossing the river by boat. Each boat can carry a maximum weight of given limit K. Each boat carries at most 2 people at the...

## Number of Islands

Objective: Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. Assume...

## Minimum No of operations required to convert a given number to 1 – Integer Replacement Problem.

Objective: Given a number N, write an algorithm to convert that number to 1. Below are the allowed operations. If N is even, do N = N/2. If N is odd, either do N...

## Evaluation of Postfix Expressions (Polish Postfix notation) | Set 2

Earlier we had discussed how to evaluate postfix expressions where operands are of single-digit. In this article, we will discuss how to evaluate postfix expressions for any number ( not necessarily single digit.) Postfix...

## Evaluation of Postfix Expressions (Polish Postfix notation) | Set 1

Postfix notation is a notation for writing arithmetic expressions in which the operands appear before their operators. There are no precedence rules to learn, and parentheses are never needed. Because of this simplicity. Let’s...

## Check if Arithmetic Expression contains duplicate parenthesis

Objective: Given an arithmetic expression, write an algorithm to find out whether the expression contains duplicate parenthesis. Duplicate Parenthesis: Two contiguous parentheses with no elements between them can be called as duplicate parenthesis.  Example:...

## Introduction to Bipartite Graphs OR Bigraphs

Bipartite Graphs OR Bigraphs is a graph whose vertices can be divided into two independent groups or sets, U and V such that each edge in the graph has one end in set U...

## Determine the order of Tests when tests have dependencies on each other

Objective: You are working on a project where QA team has automated set of test cases for the project, but these test cases have to be executed in a specific order since test cases...

## Implement Graph Using Map – Java

Earlier, we have seen Graph and its representations. A graph can be represented using adjacency list and adjacency matrix. So far we have seen the traditional implementation of the Graph. In this article, we...

## Check if given an edge is a bridge in the graph

Objective – Given a graph and an edge, write a program to check if the edge is a bridge. Bridge in Graph: An edge is called a bridge if connects two subgraphs and removing...

## Convert Prefix to Postfix Expression

Objective: Given a Prefix expression, write an algorithm to convert it into Postfix expression. Example: Input: Prefix expression:  + A B  Output: Postfix expression: A B + Input: Prefix expression:  *-A/BC-/AKL Output: Postfix expression:...

## Sort a given stack – Using Temporary Stack

Objective: Given a stack of integers, write an algorithm to sort the stack using a temporary stack.  Example: Given Stack: [14, 9, 67, 91, 101, 25] Sorted Stack: [9, 14, 25, 67, 91, 101]...