Found 26504 Articles for Server Side Programming

Golang program to implement radix sort using counting sort as a subroutine

Akhil Sharma
Updated on 06-Jul-2023 12:07:11

219 Views

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

Golang program to perform a left rotation in a Red Black Tree

Akhil Sharma
Updated on 06-Jul-2023 12:02:59

147 Views

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

Golang program to find total bonus paid to a particular employee

Akhil Sharma
Updated on 06-Jul-2023 12:00:03

142 Views

There can be some situations in which you have a list of employees and you need to find out the bonus paid to a particular employee. Go language allows you to perform the task easily, in this article we are going to find out the total bonus paid to a particular employee using a fixed bonus amount as well as calculating individual bonus percentage. Algorithm Create a struct Employee with the attributes Name and BonusPercent. Calculate the total bonus using the function calculateTotalBonus, float64: Set the variable totalBonus to 0.0. Iterate through the employees array, one ... Read More

Golang program to find which Employees should get bonus

Akhil Sharma
Updated on 06-Jul-2023 11:57:35

93 Views

In corporate office there may be some cases in which you have a list of employees and you need to provide them extra bonus based on the work or experience or a particular property. In this article we are going to explore a way to calculate bonus using performance based calculations and tenure based calculations. Method 1: Performance Based Calculations Performance is the common base to determine the employee’s bonus, in this method we are going to calculate the bonus depending on the performance of the employee. Algorithm Create the Employee struct, which has the values Name, Salary, and ... Read More

Golang program to sort Employee by Name

Akhil Sharma
Updated on 06-Jul-2023 11:51:08

208 Views

There may be scenarios in which you need a list of employees and you need to display them in a particular order based on their name initials. In this Golang article, we are going to sort employee names using bubble sort, insertion sort as well as using go sort package. Algorithm Create a field called “Name” in the Employee struct. Use the array of Employee objects as input for the “BubbleSortByEmployeeName” method. Obtain the employees array's length and save it in the variable n. Start the outer loop from i = 0 to n-1 and Start the ... Read More

Golang program to sort Employee by salary

Akhil Sharma
Updated on 06-Jul-2023 11:25:25

451 Views

There can be some scenarios in which you have a list of employees and you need to display them in a particular order based on their salaries by sorting them. In this article we are going create a go program to sort the list of employees by salary using sort.slice() functions, sort.interface interface as well as using a custom sorting function. 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, and returns the integer value that is the variable's length. ... Read More

Golang program to takes a receiving channel of integers and a sending channel of strings

Akhil Sharma
Updated on 06-Jul-2023 11:21:24

334 Views

In this article, we will learn how to develop a golang program that takes a receiving channel as integer and sends a channel of strings. Here we will be using a concurrent approach that involves using the multiple goroutines to perform transformation concurrently as well as using select statements with timeout. Syntax channel_name := make(chan Type) To create a channel. channel_name

Golang program to detect a unidirectional receiving channel of strings and a sending channel of integers.

Akhil Sharma
Updated on 05-Jul-2023 18:39:50

169 Views

Unidirectional channel is a type of channel that can only be used for either receiving or sending the data.In this article, we will create a golang program to detect a receiving channel that consist of string and a sending channel that has integers in it. Here we will learn how to utilize unidirectional channels to receive strings and send integers using unbuffered and buffered channels, select statements and using a struct to combine channels. Syntax ch := make(chan string) Creates a channel to handle strings. ch

Golang program to takes two unidirectional receiving channels and a sending channel

Akhil Sharma
Updated on 05-Jul-2023 18:35:30

332 Views

Unidirectional channel is a type of channel that will be either used for sending data or receiving data, but can’t be used for both. In this Golang article we will explore a Golang program that takes two unidirectional receiving channels and a sending channel using select statement as well as using a fan-in pattern method. We will provide code examples with algorithms and output of the code. Method 1: Using Select Statement This method allows you to handle multiple channel operations simultaneously and selecting the one which is ready to be processed. Algorithm Make three channels: channel one, channel ... Read More

Golang program to use a unidirectional channel to send integers from 1 to 10 to a receiving function

Akhil Sharma
Updated on 05-Jul-2023 18:29:35

127 Views

In this go language article we are going to use a unidirectional channel to send integers from 1 to 10 to a receiving channel. We will be using a basic channel, a buffered channel with fixed capacity as well as using a select statement for non-blocking channel operation. Syntax ch := make (chan int) To create an unbuffered channel Value :=

Advertisements