A struct is a counterpart to class in object-oriented programming where different fields can be placed in the struct, where these fields can be implemented later on and they have a type like int, float, string etc.In this article, we will write a Go language program to compare the equality of two structs. Syntax func len(v Type) int The len() method returns the length of any parameter. It accepts one input, the data type variable whose length we want to know. func range(variable) The range function iterates through any data type. To utilize this, we must first put ... Read More
A pointer is a variable which holds the address of another variable and can be used to point to the content of another variable. A pointer does not have its capacity just like slices, it can be used to point to the map whose length of elements can be calculated.In this article, we will write a Go language program to find the capacity of a pointer pointing to a map. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its ... Read More
In this article, we will write a Go language program to find the longest path in a weighted directed acyclic graph using Bellman-ford-algorithm. Bellman-Ford-Algorithm is a popular algorithm used to find the longest path from source vertex to other vertices in a weighted directed graph. Syntax func range(variable) Any data type may be iterated over using the range function. This may be used by first writing the range keyword, then the data type to which we wish to iterate. func make ([] type, size, capacity) When creating an array or map in the Go programming language, the ... Read More
In this article, we will write Go language programs to find the minimum no. of edges in a weighted directed graph that connects all nodes. We will use Prim’s algorithm to perform this operation. It is a greedy algorithm which is used to find the minimum spanning tree for a graph. Syntax func range(variable) Any data type may be iterated over using the range function. This may be used by first writing the range keyword, then the data type to which we wish to iterate func make ([] type, size, capacity) The go language's make function is used ... Read More
Bellman-ford algorithm is used to find the shortest distance from the source node to the other nodes in a weighted directed graph. This algorithm also predicts the negative weight cycles in the graph. It has a time complexity of O(V*E) where V stands for vertices and E stands for edges.In this Golang article, we will write programs to find the shortest path from source node to a target node using the Bellman-ford algorithm. Syntax func range(variable) The range function iterates through any data type. To utilise this, first type the range keyword followed by the data type to which ... Read More
In this article, we will write Go language programs to implement radix sort for sorting floating-point numbers. Radix sort is usually used for sorting the integers, it can also be used to sort floating point numbers. It sorts items based on their particular bits or digits. This article provides an effective approach to sort the floating point numbers using the representation of floating point numbers. Algorithm Step 1 − Convert the floating-point numbers to a sortable format Step 2 − Perform a Radix Sort for each digit position Step 3 − Sort the integers based on the current ... Read More
Radix sort is efficient for sorting strings because of its inherent structure of string data type.In this article, we will write a Go language program to implement radix sort for sorting strings. We start working on an unsorted array string and demonstrate how radix sort can be applied to sort it. A string is a character array or combination of characters. Syntax func make ([] type, size, capacity) The make function in Go is used to build an array/map. It receives as arguments the kind of variable to be generated, as well as its size and capacity. func range(variable) ... Read More
A subroutine is a part of a program which performs a specific task and can be called repeatedly based on the purpose and use. When a subroutine is called, the program shifts to that routine and executes the instructions inside that routine.Radix sort is an algorithm that sorts elements from their digits. It has a linear time complexity and is used for sorting large amounts of data. It uses counting sort to calculate the frequencies of digits.In this Golang article, we will write programs to implement radix sort using bucket sort as a subroutine. Syntax func len(v Type) int ... Read More
Radix sort is an algorithm that sorts elements from their digits. It has a linear time complexity and is used for sorting large amounts of data. It uses counting sort to calculate the frequencies of digits. Counting Sort is an algorithm that is efficient in sorting when the input is integer within a particular range. It counts the occurrence of each unique element from the input and uses that information to get the correct position of each element. A subroutine is a function of the program which performs a specific task and can be used when and repeatedly called in ... Read More
A red black tree is a self balancing binary search tree. Rotation is one of the fundamental operations of a self balancing tree. It is performed to maintain the tree's properties while inserting and deleting nodes to the tree. In this article we are going to write a language program to perform left rotation in a Red Black tree using pointers as well as using node value. Properties of Red Black tree Every node is either red or black The root node is always black Every leaf node is considered black If a node is red, both its children ... Read More