Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 423 of 3363
489 Views
In this article we are going to learn how to use Binary Heap method and Priority queue method to implement prims Algorithm in golang. Prim's Algorithm is used to find the minimum spanning tree of a weighted undirected graph. Algorithm Step 1 − First, we need to import the fmt and heap package. Then create the required structs and functions and define properties to them. Step 2 − Further Initialize an empty visited set and a binary heap h with the minimum edge from the starting vertex s. Step 3 − Then create the main() function. Inside the function ... Read More
510 Views
In this article we are going to understand how to develop a golang program to implement kruskals Algorithm with the help of union-find Algorithm and priority queue approach. Kruskal's Algorithm is used to find the minimum spanning tree of a graph. Algorithm Step 1 − First, we need to import the fmt and sort packages. Then create structures called Edge, graph and subset and assign properties to it. Step 2 − Then sort all the edges of the graph in non-decreasing order of their weight. Step 3 − Create a disjoint set data structure, where each set contains ... Read More
235 Views
The Depth-First Search (DFS) Algorithm is a classic Algorithm used to traverse and search graphs. In this article we are going to learn how to develop golang program where we can check if a graph is bipartie or not using DFS . Here we will use two different approaches to implement the result. Syntax func len(v Type) int The len() function is used to get the length of a any parameter. It takes one parameter as the data type variable whose length we wish to find and returns the integer value which is the length of the variable. ... Read More
544 Views
In this article we are going to understand how to use least significant bit and the most significant bit to implement radix sort. Radix sort is a sorting Algorithm that sorts elements by grouping them based on their individual digits or by the position of their digits. It is a linear time sorting Algorithm that has a time complexity of O(nk). Using the Least Significant Bit In this method, we will write a go language program to implement the radix sort by using the least significant bit. LSD sorts the elements from right to left by comparing their individual ... Read More
605 Views
In this article we are going to learn how to use recursion method and iteration to implement tower of hanoi in golang. The Tower of Hanoi is a puzzle in which we move a set of disks from one page to another by moving one disk at a time. There are certain set of rules that need to be obeyed in this puzzle. Using Recursion Approach In this method, we will write a go language program to implement tower of Hanoi by using the method of recursion. If n is 1, we can move the disk from from to ... Read More
970 Views
In this article we are going to learn how to use DFS Algorithm and breath-first searh method in golang to find all the paths in the a graph. In a graph, the nodes are depicted by the entities while the edges depict the relation between those entities. Finding all paths in a graph is a common task in graph theory and can be useful in a variety of applications. Algorithm Step 1 − First, we need to import the fmt package. Step 2 − Then create different structs and functions and define properties to them. Step 3 − Now, ... Read More
255 Views
In golang, circular linked lists are an important data structure used in computer science to efficiently manage memory and data. A circular linked list is a linked list in which the last node of the list points to the first node of the list, creating a loop. Using Traversal Method In this method, we will write a go language program to count the number of nodes in a circular linked list by traversing through it. Algorithm Step 1 − First, we need to import the fmt package. Step 2 − Now, initialize a node struct and assign two ... Read More
3K+ Views
In Swift, we can find the second largest element from the given array using the sort() function or using user defined function. For example, we have the following array − Array = [34, 23, 1, 45, 3] Hence the largest element is 45 and the second largest element is 34. So lets discuss both the methods in detail along with examples. Method 1 In this method, we find the second largest element from the specified array by creating user defined function. Example In the following example, we will create a function named as ‘secondlargestElement’, it takes an array as ... Read More
2K+ Views
In Swift, a set is used to define an unordered collection of unique elements whereas an array is used to define an ordered collection with may or may not be unique elements. To convert a set into an array Swift provides an inbuilt initializer named as Array(). Syntax Array(MySet) Where Array() initializer takes only one parameter that is the name of the set and, returns an array of the same type. Example In the following example, we will create and initialize a set of strings. Then convert the set into the array using Array() initializer and then display the ... Read More
2K+ Views
Swift provide a inbuilt method named as joined() to convert a set of string to comma separated string. This function return the concatenated elements of the given sequence by inserting the given separator in between each element of the sequence. Syntax func joined(separator: sep) Where the separator parameter contains a string or sequence, which is further used to insert between each element of the given sequence. This function returns a concatenated or joined sequence of elements. Example In the following code, we will create and initialize a set of strings. Then we join the elements of the set ... Read More