Found 1082 Articles for Go Programming

Golang program to find the diameter of a tree

Akhil Sharma
Updated on 10-May-2023 12:41:07

186 Views

In this Golang article, we are going to find the diameter of a tree by using recursion and iterative method. The diameter of a tree is the number of nodes on the longest path between any two leaves in the tree. Syntax func diameter(root *node) int{…} The diameter() function is used to find the diameter of a tree. It takes pointer to the root node as its argument. Algorithm Step 1 − First, we need to import the fmt package. Step 2 − Now, create a struct of a single node of the tree named, node. It contains ... Read More

Golang program to delete duplicate value nodes from a sorted linked list

Akhil Sharma
Updated on 10-May-2023 12:39:48

219 Views

In this Golang article, we are going to delete duplicate value nodes from a sorted linked list by using recursion and iterative method. A linked list is a data structure consisting of a collection of nodes, where each node contains a value and a pointer to the next node in the list. Syntax func deleteDuplicates(head *Node) *Node{…} The deleteDuplicates() function is used to delete duplicate value nodes from a sorted linked list. It takes pointer to the head node as its argument. Algorithm Step 1 − First, we need to import the fmt package. Step 2 − Now, ... Read More

Golang program to print left pascals triangle

Akhil Sharma
Updated on 10-May-2023 12:36:56

157 Views

In this Golang article, we will learn how to print left Pascal’s triangle by using recursion and iterative method. Pascal's triangle is a triangular array of binomial coefficients. The left pascal's triangle is a variant of Pascal's triangle that is obtained by reflecting Pascal's triangle along a vertical axis. Syntax func leftPascal(n, k int) int{…} The leftPascal() function is used to print left Pascal’s triangle. It takes two arguments as input. func leftPascal(n int){…} The leftPascal() function is used to print left Pascal’s triangle. It takes one argument, number of rows as input. Algorithm Step 1 − ... Read More

Golang program to find maximum element in array using linear search

Akhil Sharma
Updated on 10-May-2023 12:17:27

2K+ Views

In this Golang article, we will learn how to find maximum element in array using linear search by using recursion and iterative method. Syntax func findMax(arr []int) int {…} The findMax() function is used to find maximum element in array using linear search iteratively. It takes an integer array as argument to it. func findMax(arr []int, n int) int {…} The findMax() function is used to find maximum element in array using linear search recursively. It takes an integer array and the size of the array as arguments to it. Algorithm Step 1 − First, ... Read More

Golang program to find the first occurrence of a specific element in array using linear search

Akhil Sharma
Updated on 10-May-2023 12:13:09

208 Views

In this Golang article, we will find the first occurrence of a specific element in array using linear search by using recursion and iterative method. Linear search is a simple search algorithm that checks every element in a list or array one by one, starting from the beginning, until a target value is found or the entire list has been searched. It is also known as sequential search. Syntax func firstOcc(arr []int, target int) int {…} The firstOcc() function is used to find the first occurrence of a specific element in array using linear search iteratively. It takes an ... Read More

Golang program to find minimum element in array using linear search

Akhil Sharma
Updated on 10-May-2023 11:59:28

692 Views

In this Golang article, we will learn how to find the minimum element in an array using linear search by using recursion and iterative method. An array is a collection of elements of the same data type, arranged in a contiguous block of memory, and accessed using an index or a subscript. Linear search is a simple search algorithm that checks every element in a list or array one by one, starting from the beginning, until a target value is found or the entire list has been searched. It is also known as sequential search. Syntax func minFind(arr []int) int ... Read More

Golang program to reverse a circular linked list

Akhil Sharma
Updated on 14-Jul-2023 16:44:56

74 Views

In this article, we will learn how to create a golang program to reverse a circular linked list using recursion and iterative method. A circular linked list is a type of linked list where the last node in the list points back to the first node, forming a loop. It could be used to implement a circular buffer or a round-robin scheduling algorithm. Syntax func reverseList(head **Node){…} The reverseList() function is used to reverse a circular linked list. It takes an argument as value to the pointer to the address of the head node. func reverseList(current, prev, head *Node) ... Read More

Renaming Linux Files in Batches

Bamdeb Ghosh
Updated on 08-May-2023 11:19:56

113 Views

Introduction If we want to rename any file in Linux, we use “mv” command. But mv command can only rename one file at a time, it can not rename multiple files at one time in terminal. If we want to rename multiples files then we have to use mv command in different way . Also there are other commands available like “rename” , “mmv”, “renameutils” etc. Though some of these commands are not installed default in Linux , we need to install them separately. In this artile, let us understand each command with some example. Approach 1: Using “mv” command ... Read More

How to pass a Slice to Function in Golang?

Siva Sai
Updated on 08-May-2023 11:07:56

981 Views

Golang, also known as Go, is a popular programming language that is known for its simplicity, efficiency, and performance. Slices are an important data structure in Golang that allows us to work with a sequence of elements of the same type. In this article, we'll discuss how to pass a slice to a function in Golang, and provide a step-by-step guide on how to achieve this task. What is a Slice in Golang? A slice in Golang is a dynamic array, which means it can grow or shrink as needed. It's a powerful data structure that allows us to work ... Read More

How to Map a Rune to Uppercase in Golang?

Siva Sai
Updated on 08-May-2023 11:07:26

340 Views

Golang, also known as Go, is a powerful programming language that offers efficient and scalable solutions for building modern software. One of the essential features of Golang is the ability to handle Unicode characters, which makes it possible to work with various languages and scripts. In this article, we'll discuss how to map a rune to uppercase in Golang, and provide a step-by-step guide on how to achieve this task. What is a Rune in Golang? A rune in Golang is a Unicode code point, which represents a single character. In Golang, the type for a rune is rune, and ... Read More

Advertisements