Found 33676 Articles for Programming

Travelling Salesman Problem using Genetic Algorithm

Ayush Singh
Updated on 14-Jul-2023 10:02:20

4K+ Views

The Travelling Salesman Problem (TSP) finds the shortest path between a collection of cities and the starting point. Due of its combinatorial nature and exponentially increasing number of routes as cities rise, it is a difficult task.The Genetic Algorithm (GA) is a genetically inspired heuristic. Emulating natural selection solves the TSP. The GA uses routes to illustrate prospective city tours.Selection, crossover, and mutation develop the population in the GA. Selection favours pathways with higher fitness, indicating quality or near to the ideal solution. Mutation introduces random modifications to explore new solution spaces, whereas crossover mixes genetic information from parent routes ... Read More

Golang Program to Create an Interface Named Mailer that Defines a Send Method

Akhil Sharma
Updated on 13-Jul-2023 23:11:45

108 Views

In this article we are going to create an interface named mailer that defines a send method using interfaces embedding as well as Function as parameter. Interface in go language is a collection of methods that define a set of behavior. Algorithm Create a Mailer interface with a Send function that accepts two parameters: the recipient's email address and the email body. If an error occurs during the sending procedure, the Send method should return an error. Example 1 Make structs that represent various mailer implementations, such as SmtpMailer, SendGridMailer, and so on. ... Read More

Golang Program to Create an Interface Named Writer that Defines a Write Method

Akhil Sharma
Updated on 13-Jul-2023 23:07:58

144 Views

In this Golang article we will learn to create an interface named writer that defines a write method write method for file type as well as writer interface and filet type. Syntax data := []byte("Hello, World!") It is used to declare a byte slice in go language. data : it is a variable declaration for a var named data. []byte: the type of variable “data” as a byte slice. ... Read More

Shortest Path with Exactly k Edges in a Directed and Weighted Graph

Ayush Singh
Updated on 14-Jul-2023 09:59:24

376 Views

In a coordinated and weighted chart, the issue of finding the most brief way with precisely k edges includes deciding the way that has the least weight while navigating precisely k edges. This will be accomplished by employing dynamic programming strategies, such as employing a 3D framework to store the least weight of all conceivable ways. The calculation repeats over the vertices and edges, overhauling the least weight at each step. By considering all conceivable ways with precisely k edges, the calculation distinguishes the most limited way with k edges within the chart. Methods Used Naive Recursive approach Dijkstra's ... Read More

Maximize the Number of Uncolored Vertices Appearing Along the Path from Root Vertex and the Colored Vertices

Ayush Singh
Updated on 14-Jul-2023 09:53:10

110 Views

Go through the entire graph and compute the difference between the depth of each vertex and the number of vertices in its subtree to maximise the number of uncolored vertices that occur along the path from the root vertex to the coloured vertex. Find the uncolored vertex that has the greatest influence on the route by choosing the 'k' largest deviations. The sum of these parallaxes gives the maximum number of uncolored vertices. This method allows us to aggressively optimise the number of colourless vertices that occur, improving overall results and emphasising the importance of colourless vertices on the way ... Read More

Golang Program to Create Filter for the Employees Based on their Salary

Akhil Sharma
Updated on 13-Jul-2023 23:03:25

181 Views

It is important to have the knowledge of filters while working on data sets in go language because there may be cases where you want to analyze data to get customized results. In this article we are going to create a filter on the employee list based on the salary using traditional looping method, functions approach as well as using goroutines. Example 1 In the code given below “FilterEmployeeBySallary()” filters the list of employee based on a salary range and returns the list of employee that falls in that salary range. package main import "fmt" type Employee struct ... Read More

Maximum Clique Problem|Recursive Solution

Ayush Singh
Updated on 14-Jul-2023 09:51:03

602 Views

Finding the biggest complete subgraph, or clique, in a given graph is the goal of the famous Maximal Clique Problem in graph theory. Each vertex in a clique is connected to every other vertex in the clique by a direct edge. The technique iteratively adds vertices connecting to all vertices in the current clique to investigate all possible expansions of the clique. In order to quickly explore the search space, it employs backtracking, eliminating potential paths that would not end in maximum cliques.Using the recursive method, we can efficiently discover and label all maximum cliques in a given graph, yielding ... Read More

Implementation of BFS using Adjacency Matrix

Ayush Singh
Updated on 14-Jul-2023 09:49:09

6K+ Views

A simple graph traversal algorithm called Breadth−First Search (BFS) is employed to examine a graph step by step. Before going to an additional stage of vertices, it begins with a certain vertex (source) and checks all of its neighbours in an ordered way. In this blog post, we'll look at three different ways to use an adjacency matrix in CPP methods to construct BFS. We'll go over the algorithm used by each technique, offer relevant code representations, and demonstrate each method's unique results. Methods Used Iterative BFS BFS with Level Information BFS Shortest Path Iterative BFS ... Read More

Golang program to create filter for the Employees

Akhil Sharma
Updated on 14-Jul-2023 15:55:13

745 Views

Go Language allows you to apply a filter on particular data for analyzing specified data, work on a particular property of data, data integration and more.In this article we are going to write a program to create a filter for the employees, using iterative filtering, functional filtering, as well as using go language built in filtering function. Syntax filtered := funk.Filter(collection, func(item Type) bool {…}) collection = It is the original collection to filter. This function takes two arguments, a collection and a filtering function. Algorithm Make ... Read More

Find the Minimum Spanning Tree with Alternating Colored Edges

Ayush Singh
Updated on 14-Jul-2023 09:46:55

186 Views

The code executes a calculation to discover the least crossing tree by substituting coloured edges. It employs an energetic programming approach to calculate the least expensive toll. The calculation considers all conceivable edges and colours and recursively assesses the cost of counting or barring each edge based on whether it keeps up the substituting colour design. It keeps track of the least severe toll experienced so far by employing the memoization method. The calculation develops the least crossing tree by eagerly selecting edges with the least toll, guaranteeing that adjoining edges have distinctive colours. At last, it returns the least−fetched ... Read More

Advertisements