Akhil Sharma has Published 507 Articles

Golang program to find the depth of a node in a binary search tree

Akhil Sharma

Akhil Sharma

Updated on 03-Apr-2023 13:09:43

680 Views

In this Golang article, we are going to find the depth of a node in a binary search tree using recursion and iterative method. The binary search tree is a useful data structure for efficient searching, insertion, and deletion of elements. A binary search tree (BST) is a type of ... Read More

Golang program to find intersection of two sorted arrays using two pointer approach

Akhil Sharma

Akhil Sharma

Updated on 03-Apr-2023 13:08:56

577 Views

In this Go language article, we will write programs to find intersection of two arrays using two pointer approach. Intersection means similarity or most common and intersection of two arrays refers to the similar elements between two arrays. Syntax func make ([] type, size, capacity) The make function in ... Read More

Golang program to implement depth first search

Akhil Sharma

Akhil Sharma

Updated on 03-Apr-2023 13:07:14

5K+ Views

In this article, we are going to learn how to use internal Golang functions like make, append, and range to implement depth first search. Depth first search is a traversal algorithm used for graph and tree data structures. It explores all the nodes of the graph recursively. Syntax func make ... Read More

Golang program to get the individual components of the current date-time

Akhil Sharma

Akhil Sharma

Updated on 03-Apr-2023 13:05:21

312 Views

In this article, we are going to learn how to use various internal time function in Golang that will get the individual components of the current date-time. Now function from the time package will be used to get the current date-time and the individual components of date-time are calculated using ... Read More

Golang program to display time in different country’s format

Akhil Sharma

Akhil Sharma

Updated on 03-Apr-2023 13:01:42

491 Views

In Golang we can use the functions like time.Format() and Now() Time to display the time in different country’s format. Now function from the time package is used to get the current local time and the format function is used to format the time string using different format strings. Syntax ... Read More

Golang program to demonstrate the argument passing to block

Akhil Sharma

Akhil Sharma

Updated on 03-Apr-2023 12:58:54

223 Views

In this article, we are going to learn how to demonstrate the argument to block using the user-defined function, iterations, and square of numbers . A block is created using curly braces with a definite begin and end braces. The different operations are performed inside the braces. Algorithm Step ... Read More

Golang program to get the current day of the year out of 365

Akhil Sharma

Akhil Sharma

Updated on 03-Apr-2023 12:54:49

943 Views

In Golang we can use functions like YearDay and Sub as well as arithmetic operation method to get the current day of the year out of 365. The current time is obtained using the Now function from the time package and YearDay() function is used to obtain the current day ... Read More

Golang program to add two dates

Akhil Sharma

Akhil Sharma

Updated on 03-Apr-2023 12:49:14

467 Views

In this Golang article, we will write programs to add two dates. The dates are added using methods like Add(), AddDate(). There are different formats to represent a date. Here, the dates after addition will be represented using YY/MM/DD format. Syntax func (t Time) Sub(u Time) Duration The sub() ... Read More

Haskell Program to Convert String value to byte Value

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 15:21:13

429 Views

In Haskell, we will convert String Value to Byte value by using ord , B.pack and fromNum functions. In the first example, we are going to use (stringToBytes = map ord ) function and in the second example, we are going to call (stringToBytes = B.pack) function. And in the ... Read More

Haskell Program to Convert List to a Map

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 14:57:54

848 Views

In Haskell, we will convert List to a Map by using fromList and foldl functions. This can also be done using recursion and pattern matching. In the first example, we are going to use (listToMap xs = Map.fromList xs) function and in the second example, we are going to use ... Read More

Advertisements