Samual Sam has Published 2310 Articles

Word Break Problem

Samual Sam

Samual Sam

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

520 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

12K+ 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

Count Inversions in an array

Samual Sam

Samual Sam

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

562 Views

The inversions of an array indicate; how many changes are required to convert the array into its sorted form. When an array is already sorted, it needs 0 inversions, and in another case, the number of inversions will be maximum, if the array is reversed.To solve this problem, we will ... Read More

Biconnected Graph

Samual Sam

Samual Sam

Updated on 16-Jun-2020 09:20:10

4K+ Views

An undirected graph is said to be a biconnected graph, if there are two vertex-disjoint paths between any two vertices are present. In other words, we can say that there is a cycle between any two vertices.We can say that a graph G is a bi-connected graph if it is ... Read More

How to count Java comments of a program that is stored in a text file?

Samual Sam

Samual Sam

Updated on 16-Jun-2020 08:49:25

537 Views

You can read the contents of a file using the Scanner class and You can find the comments in a particular line using contains() method.Exampleimport java.io.*; import java.util.Scanner; public class FindingComments {    public static void main(String[] args) throws IOException {       Scanner sc = new Scanner(new File("HelloWorld")); ... Read More

Why should we use

Samual Sam

Samual Sam

Updated on 16-Jun-2020 06:25:03

47 Views

To find whether the browser supports JavaScript or not, use the tag. The HTML tag is used to handle the browsers, which do recognize tag but do not support scripting. This tag is used to display an alternate text message.ExampleLive Demo           ... Read More

Adding an element in an array using Javascript

Samual Sam

Samual Sam

Updated on 15-Jun-2020 14:41:58

225 Views

Adding an element to an array can be done using different functions for different positions.Adding an element at the end of the arrayThis can be accomplished using the push method. For example, let veggies = ["Onion", "Raddish"]; veggies.push("Cabbage"); console.log(veggies);This will give the output −["Onion", "Raddish", "Cabbage"]You can also use this ... Read More

Dijkstra's algorithm in Javascript

Samual Sam

Samual Sam

Updated on 15-Jun-2020 12:14:29

6K+ Views

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a weighted graph. We'll use the new addEdge and addDirectedEdge methods to add weights to the edges when creating a graph. Let us look at how this algorithm works −Create a distance collection and set all vertices ... Read More

Minimum spanning tree (MST) in Javascript

Samual Sam

Samual Sam

Updated on 15-Jun-2020 12:10:17

627 Views

A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges of a connected, edge-weighted (un)directed graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight. That is, it is a spanning tree whose sum of edge ... Read More

Kruskal's algorithm in Javascript

Samual Sam

Samual Sam

Updated on 15-Jun-2020 12:06:01

1K+ Views

Kruskal's algorithm is a greedy algorithm that works as follows −1. It Creates a set of all edges in the graph.2. While the above set is not empty and not all vertices are covered, It removes the minimum weight edge from this setIt checks if this edge is forming a ... Read More

Advertisements