Samual Sam has Published 2492 Articles

Count Inversions in an array

Samual Sam

Samual Sam

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

373 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

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

360 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

4 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

Activity Selection Problem

Samual Sam

Samual Sam

Updated on 15-Jun-2020 16:28:54

4K+ Views

There are n different activities are given with their starting time and ending time. Select the maximum number of activities to solve by a single person. We will use the greedy approach to find the next activity whose finish time is minimum among rest activities, and the start time is ... Read More

Adding an element in an array using Javascript

Samual Sam

Samual Sam

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

134 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

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

451 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

What is the difference between window.onload and document.onload in Javascript?

Samual Sam

Samual Sam

Updated on 15-Jun-2020 12:05:46

1K+ Views

document.onloadIt gets fired prior to loading of images and other external content. document.onload event is fired before the window.onload.window.onloadIt gets fired when the complete page loads, which includes images, scripts, css, etc.ExampleHere’a an example to understand onload.Live Demo           JavaScript Animation         ... Read More

Advertisements