Akhil Sharma

Akhil Sharma

507 Articles Published

Articles by Akhil Sharma

Page 15 of 51

Haskell Program to Print 8-Star Pattern

Akhil Sharma
Akhil Sharma
Updated on 06-Apr-2023 213 Views

In this tutorial, we are going to learn how to develop a Haskell program to print 8 start patterns using the internal replicate and concat function. An '8' star pattern is an ASCII art representation of the number 8 using asterisks. as shown below − ******** * * * * ******** * * * * ******** The asterisks are arranged in such a way that they form the shape of the number 8. Algorithm Step 1 − ...

Read More

Haskell Program to Create Pyramid ‘and’ Pattern

Akhil Sharma
Akhil Sharma
Updated on 06-Apr-2023 280 Views

In this tutorial, we are going to understand how to develop a Haskell program that will create a pyramid pattern of ‘&’ using mapM, forM, and recursive function. A pyramid ‘&’ pattern is a design or arrangement of ‘&’ or other symbols in the shape of a pyramid as shown below. & &&& &&&&& &&&&&&& &&&&&&&&& It is created by printing ‘&’ or symbols in multiple rows, starting from the top and moving downwards. Each row contains one more symbol than the previous row, creating the illusion of ...

Read More

Haskell Program to Print Star Pascal’s Triangle

Akhil Sharma
Akhil Sharma
Updated on 06-Apr-2023 594 Views

In Haskell we can use mapM function and forM function to print a star Pascal’s Triangle. A star Pascal's triangle is a variation of the traditional Pascal's triangle that uses asterisks (or stars) instead of numbers to form a triangular pattern as shown below. * * * * * * * * * Pascal's triangle is a triangular array of numbers, where each number in the triangle is the sum of the two numbers above it. In ...

Read More

Haskell Program to Print Upper Star Triangle Pattern

Akhil Sharma
Akhil Sharma
Updated on 06-Apr-2023 232 Views

This tutorial will help us in printing the upper star triangle pattern using mapM function, forM function, and unliness functions in Haskell. An upper star triangle pattern is a graphical representation of a triangle made up of asterisks or stars as shown below. * ** *** **** ***** It's called an "upper" star triangle because the triangle starts at the top and the number of stars in each row decreases as we move down the triangle. Algorithm Step 1 − We will start with defining a user-defined function as printStars function. Step 2 − Program execution will be ...

Read More

Golang program to implement dijikstra Algorithm to find shortest path between two nodes in a graph

Akhil Sharma
Akhil Sharma
Updated on 05-Apr-2023 2K+ Views

In this Golang article, we will explore how to implement Dijkstra's Algorithm to find the shortest path between two nodes in a graph using an Adjacency Matrix as well as using an Adjacency List. Dijkstra's Algorithm is used to solve the single-source shortest path problem in a graph with non-negative edge weights. Algorithm Step 1 − First, we need to import the fmt and math packages. Then create a dist array of length n (the number of nodes in the graph) and initialize it with math.MaxInt32. This array will store the shortest distance from the starting node to every ...

Read More

Golang program to implement merge sort

Akhil Sharma
Akhil Sharma
Updated on 05-Apr-2023 1K+ Views

In this Golang article, we will learn how to implement Merge Sort in Golang using three different methods recursions, iteration and goroutines. Merge sort is one of the most efficient sorting Algorithms that uses the divide and conquer approach to sort a list of elements. Syntax func copy(dst, str[] type) int The copy function in go language is used to copy the values of one source array to the destination array and returns the number of elements copied as the result. It takes the two arrays as an argument. func len(v Type) int The len() function is used ...

Read More

Golang program to find the minimum number of resources needed to complete all tasks simultaneously

Akhil Sharma
Akhil Sharma
Updated on 05-Apr-2023 220 Views

In this Golang article, w will understand how to use interval scheduling Algorithm find the minimum number of resources needed to complete all the tasks simultaneously. Interval scheduling Algorithm is a type of Algorithm used to solve scheduling problems where a set of tasks with start and end times must be scheduled on a limited resource. Algorithm Step 1 − First, we need to import the fmt and Sort packages. Then initialize the required structs along with the functions. Step 2 − The task struct is used to track the start and end time of the task whereas ...

Read More

Golang program to find the maximum number of classes that can be scheduled without conflicts

Akhil Sharma
Akhil Sharma
Updated on 05-Apr-2023 169 Views

In this Golang article we are going to find the maximum number of classes that can be scheduled without conflicts, if there is a list of intervals representing classes. Here we are going to slice function to perform this task. Following Algorithm will help you understand the steps taken to creat the golang program. Algorithm Step 1 − First, we need to import the fmt and sort packages. Step 2 − Then, create a struct named interval and store in it the start and end variable. Step 3 − Now, start the main() function. Inside the main() Initialize the ...

Read More

Golang program to find minimum spanning tree using dijkstra Algorithm

Akhil Sharma
Akhil Sharma
Updated on 05-Apr-2023 669 Views

In this article we will write a go language program to find minimum spanning of tree. A minimum spanning tree (MST) is a tree that connects all the nodes in an undirected, weighted graph with the minimum possible edges. There are several Algorithms to find the minimum spanning tree of a graph like dijkastra Algorithm, prim's Algorithm and kruskal's Algorithm. What is Dijkistra Algorithm? Dijkstra's Algorithm is an Algorithm that finds the shortest path between a source vertex and all other vertices in a weighted graph with non-negative edge weights. It works by maintaining a set of visited vertices ...

Read More

Golang program to find the last occurrence of a target element in a sorted slice

Akhil Sharma
Akhil Sharma
Updated on 05-Apr-2023 301 Views

In this article, we will learn how to write a golang program to find the last occurrence of a target element in a sorted slice using linear and binary search approach. We will use two programs in this article. In the first program we will use the Linear search approach while in the second one we will use the binary search approach to implement the result. Using the Linear Search Approach The simplest method to find the last occurrence of a target element in a sorted slice is to perform a linear search. In this method, we iterate through the ...

Read More
Showing 141–150 of 507 articles
« Prev 1 13 14 15 16 17 51 Next »
Advertisements