Samual Sam has Published 2492 Articles

Eulerian Path and Circuit

Samual Sam

Samual Sam

Updated on 16-Jun-2020 13:20:51

7K+ Views

The Euler path is a path, by which we can visit every edge exactly once. We can use the same vertices for multiple times. The Euler Circuit is a special type of Euler path. When the starting vertex of the Euler path is also connected with the ending vertex of ... Read More

Longest Path in a Directed Acyclic Graph

Samual Sam

Samual Sam

Updated on 16-Jun-2020 12:46:03

1K+ Views

One weighted directed acyclic graph is given. Another source vertex is also provided. Now we have to find the longest distance from the starting node to all other vertices, in the graph.We need to sort the nodes in topological sorting technique, and the result after the topological sort is stored ... Read More

Shortest path with exactly k Edges

Samual Sam

Samual Sam

Updated on 16-Jun-2020 12:34:11

444 Views

One directed graph is provided with the weight between each pair of vertices, and two vertices u and v are also provided. Our task is to find the shortest distance from vertex u to vertex v, with exactly k number of edges. To solve this problem, we will start from vertex ... Read More

Connectivity in a directed graph

Samual Sam

Samual Sam

Updated on 16-Jun-2020 11:35:48

2K+ Views

To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any node, which is not visited, then the graph is not connected.For the directed graph, we will start traversing from all nodes to check connectivity. Sometimes ... Read More

Detect Cycle in a an Undirected Graph

Samual Sam

Samual Sam

Updated on 16-Jun-2020 11:27:25

7K+ Views

To detect if there is any cycle in the undirected graph or not, we will use the DFS traversal for the given graph. For every visited vertex v, when we have found any adjacent vertex u, such that u is already visited, and u is not the parent of vertex ... Read More

How to switch data from an array to array list in java?

Samual Sam

Samual Sam

Updated on 16-Jun-2020 11:14:27

222 Views

The Arrays class of the java.util package provides you a method named asList(). This method accepts an array (of objects) and converts them into a list and returns it.ExampleLive Demoimport java.util.Arrays; import java.util.List; public class ArrayToList {    public static void main(String args[]) {       Integer[] myArray ... Read More

Bridges in a Graph

Samual Sam

Samual Sam

Updated on 16-Jun-2020 10:48:32

1K+ Views

An edge in an undirected graph is said to be a bridge, if and only if by removing it, disconnects the graph, or make different components of the graph. In a practical approach, if some bridges are present in a network when the connection of bridges is broken, it can break ... Read More

The Knight’s tour problem

Samual Sam

Samual Sam

Updated on 16-Jun-2020 09:51:09

4K+ Views

In chess, we know that the knight can jump in a special manner. It can move either two squares horizontally and one square vertically or two squares vertically and one square horizontally in each direction, So the complete movement looks like English letter ‘L’.In this problem, there is an empty ... Read More

Word Break Problem

Samual Sam

Samual Sam

Updated on 16-Jun-2020 09:42:44

518 Views

In the input of this problem, one sentence is given without spaces, another dictionary is also provided of some valid English words. We have to find the possible ways to break the sentence in individual dictionary words.We will try to search from the left of the string to find a ... Read More

Closest Pair of Points Problem

Samual Sam

Samual Sam

Updated on 16-Jun-2020 09:37:05

10K+ Views

In this problem, a set of n points are given on the 2D plane. In this problem, we have to find the pair of points, whose distance is minimum.To solve this problem, we have to divide points into two halves, after that smallest distance between two points is calculated in ... Read More

Advertisements