Found 33676 Articles for Programming

Golang Program to Multiply to Matrix Using Multi-Dimensional Arrays

Akhil Sharma
Updated on 06-Jan-2023 16:27:51

2K+ Views

In this tutorial, we will write a go language program to multiply two matrices. The difference between a single-dimensional array and a multi-dimensional array is that the former holds an attribute while the latter holds another array on the index. Additionally, every element of a multidimensional array will have the same data type. Method 1: Multiply Two Matrices using Multi-Dimensional Arrays in the Main Function In this method, we will write a golang program to multiply two Multi-dimensional matrices using for loops in the main() function. Algorithm Step 1 − Import the fmt package. Step 2 − Now, ... Read More

Golang Program To Sort An Array In Ascending Order Using Insertion Sort

Akhil Sharma
Updated on 06-Jan-2023 16:24:53

737 Views

Insertion sort is defined as an In-Place Algorithm and it is declared as a stable algorithm. The idea of sorting an array in ascending or descending order by swapping an element can be used to implement Insertion Sort. For instance, if the array contains only one item in the list, then it is considered sorted. Otherwise, we consider that a certain portion of the list of elements is sorted while other is unsorted. Proceeding with this assumption, we traverse through the unsorted list, picking one element at a time. Syntax rand.Seed(value) Rand.Seed() function is used to generate random ... Read More

Golang Program To Iterate Over Each Element From The Arrays

Akhil Sharma
Updated on 06-Jan-2023 16:21:13

912 Views

In this tutorial, we will write a go language program to iterate over each element of the array. An array is a data structure that is used to store data at contiguous memory locations. There are many methods to iterate over an array. The simplest one is to use a for loop. Here, we will see how we can iterate over the integer and string types of arrays using various methods in go. Method 1: Iterate over the Array using For Loop In this method, we will write a go language program to iterate over the array using for loops. ... Read More

Golang Program To Find The Transpose Of A Matrix

Akhil Sharma
Updated on 06-Jan-2023 16:18:57

963 Views

In this article, we will write a go language program to find the transpose of a matrix. A matrix is a collection of numbers arranged in rows and columns, a two-dimensional array. Transpose of a matrix is defined as a matrix obtained by interchanging the rows and columns of that matrix. Method 1: Find the Transpose of a Matrix using For Loop In this example, we will write a go language program to find the transpose of the matrix using for loops in the main function. Algorithm Step 1 − Import the fmt package. Step 2 − Call the main() ... Read More

Golang Program To Display Upper Triangular Matrix

Akhil Sharma
Updated on 06-Jan-2023 16:15:37

315 Views

In this article, we will write a go language program to print the upper triangular matrix of any given matrix. Introduction − A square matrix is called an upper triangular matrix if it has zero values below the principal diagonal. A matrix is displayed in its upper triangular form only if it is square. i.e. it must have the same number of rows and columns. The order of a typical upper triangular matrix is N X N. Method 1: Display Upper Triangular Matrix using For Loops In this method, we will write a go language program to display upper ... Read More

Golang Program To Remove Duplicates From An Array

Akhil Sharma
Updated on 06-Jan-2023 16:10:26

5K+ Views

In this article, we will write a go language program to remove duplicates from an array. To achieve this we will be using two approaches. In the first one, we will use the array of strings, and in the second one; we will be using an array of integers. Method 1: Remove Duplicates from an Array of Strings using The Make() Function In this example, we will write a go language program to remove duplicates from the array of strings using a user-defined function. The function will accept the array of strings as an argument and will return the final ... Read More

Swift Program to Add Two Matrix Using Multi-dimensional Arrays

Ankita Saini
Updated on 09-Jan-2023 14:34:18

600 Views

In this article, we will learn how to write a swift program to add two matrices using a multi-dimensional array. A matrix is a mathematical structure in which the elements are present in rows and columns format. For example, the first element is present at the a00 location, the second at a01, and so on. Therefore, to add two matrices we are going to use + operator to add the elements of two matrices like a00 + b00 and then store the sum into a new matrix. For example: Matrix 1 − $\mathrm{\begin{bmatrix}2 & 3 & 4 ewline5 & 2 ... Read More

How to store/update Hashtable Elements?

Shilpa Nadkarni
Updated on 06-Jan-2023 15:14:33

2K+ Views

A hashtable is a data structure that consists of a collection of key-value pairs. The hashtable collection uses a hash function to compute the hash code of the key. A hashtable can also be defined as a non-generic collection of key-value pairs. The hash code of each key is computed using a hash function and is stored in a different bucket internally. At the time of accessing values, this hash code is matched with that of the specified key, and results are returned. Unlike other data structures like the stack, queue, ArrayList, etc. that store single values, hashtable collection stores ... Read More

How to Get Hashtable Elements as Sorted Array?

Shilpa Nadkarni
Updated on 06-Jan-2023 14:54:08

2K+ Views

A Hashtable is a non-generic collection of key-value pairs that are arranged as per the hash code of the key. A Hashtable is used to create a collection that uses a hash table for storage. The hashtable optimizes the lookup by calculating the hash code of each key and stores it internally into a basket. When we access the particular value from the hashtable, this hashcode is matched with the specified key. This hashtable collection is defined in the System.Collections namespace of C#. The class that represents the hashtable collection is the “Hashtable” class. This class provides constructors, methods, and ... Read More

How to Convert Hashtable to String?

Shilpa Nadkarni
Updated on 06-Jan-2023 14:48:49

3K+ Views

The hashtable collection in C# is a non-generic collection of elements. Each element of the hashtable is represented as a key-value pair. The keys of the hashtable are non-null and unique. The values can be duplicated and/or null. The Hashtable class of C# Systems.The collections interface is the representation of a hashtable collection. This class provides various constructors, methods, and properties to manipulate the hashtable collection. We can also convert hashtables into other collections like arrays, ArrayList, etc., and also to a string representation. In this article, let’s discuss how we can convert a hashtable collection into a string. How ... Read More

Advertisements