Server Side Programming Articles

Page 1686 of 2109

Golang Program To Determine If a Given Matrix is a Sparse Matrix

Akhil Sharma
Akhil Sharma
Updated on 10-Jan-2023 289 Views

In this tutorial, we will write a go language program to determine whether a given matrix is sparce or not. A square matrix is called a sparse matrix if the number of zeroes present in the matrix are more than the non-zero elements in the matrix. Golang Program to Check if a Matrix is Sparce In this example, we will write a Golang program to check the sparce matrix. We will use for loops along with if conditions to achieve the result in the main section of the program. Algorithm Step 1 − First, we need to import the fmt ...

Read More

Golang Program To Get The Last Item From The Array

Akhil Sharma
Akhil Sharma
Updated on 10-Jan-2023 2K+ Views

In this tutorial, we will write a go language program to get the last item from an array. An array is a data structure that is used to store elements in contiguous memory locations. In this article, we will write two programs to store the first element in the array. In the first program, we will use the concept of indexing and in the second we will use the for loops to get the required result. Method 1: Get the Last Item from the Array of Integers in the Main In this method, we will write a golang program ...

Read More

Golang Program to Calculate Difference Between Two Time Periods

Akhil Sharma
Akhil Sharma
Updated on 10-Jan-2023 13K+ Views

In this tutorial, we will write a golang programs to calculate the difference between two time periods given in the following programs. To get the time difference between two time periods we can either use a library function or can create a separate user-defined function to achieve the results. Method 1: Calculate the Difference between Two Time Periods using Internal Function In this method, we will write a go language program to find the difference between time periods using pre-defined functions in go programming language. Syntax func (t Time) Sub(u Time) Duration The sub() function in go is ...

Read More

Golang Program To Append An Element Into An Array

Akhil Sharma
Akhil Sharma
Updated on 10-Jan-2023 15K+ Views

In this tutorial, we will write a go language program to iterate over an array. An array is a data structure, which is used to store data at contiguous memory locations. There are many methods to append an element in an array. We shall discuss them in this program Example 1: Add Values to an Array of Strings in the Main() Function In this example, we will write a go language program to add values to an array of strings in the main() function. We will first initialize an array of strings of specific size and then add values ...

Read More

Parallel Computing with Dask

Prerna Tiwari
Prerna Tiwari
Updated on 09-Jan-2023 682 Views

Dask is a flexible open-source Python library which is used for parallel computing. In this article, we will learn about parallel computing and why we should choose Dask for this purpose. We will compare it with various other libraries like spark, ray and modin. We have also discussed use cases of Dask. Parallel Computing A type of computation known as parallel computing carries out several computations or processes simultaneously. Large issues are typically divided into manageable pieces that may be solved separately. The four categories of parallel computing are Bit-level Instruction-level Data-level Job parallelism. ...

Read More

Swift Program to Subtract Two Matrix Using Multi-dimensional Arrays

Ankita Saini
Ankita Saini
Updated on 09-Jan-2023 453 Views

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

Read More

Swift Program to Remove Duplicate Elements From an Array

Ankita Saini
Ankita Saini
Updated on 09-Jan-2023 9K+ Views

In this article, we will learn how to write a swift program to remove duplicate elements from an array. As we know that an array can store multiple elements of the same type. It is not necessary that all the elements are unique they can be duplicated. For example, arr = [3, 5, 6, 3, 7, 8, 3, 7, 7] here 3 and 7 are duplicate elements. So here we use the following methods to remove duplicate elements − Using contains() method Using Set() initializer Method 1: Using contains() method To remove duplicate elements from the array we ...

Read More

Swift Program to Print Matrix numbers containing in Z form

Ankita Saini
Ankita Saini
Updated on 09-Jan-2023 214 Views

In this article, we will learn how to write a swift program to print a matrix in Z form. Here we traverse through the first row then the secondary diagonal and then the last row of the matrix to print the z form. For example, 4x4 Matrix − $\mathrm{\begin{bmatrix}4 & 1 & 4 & 1 ewline1 & 3 & 1 & 3ewline2 & 1 & 1 & 2ewline1 & 6 & 6 & 1\end{bmatrix}}$ So the Z form numbers are − $\mathrm{\begin{bmatrix}4 & 1 & 4 & 1 ewline & & 1 & ewline & 1 & & ...

Read More

Swift program to Print an Identity Matrix

Ankita Saini
Ankita Saini
Updated on 09-Jan-2023 284 Views

In this article, we will learn how to write a swift program to print an identity matrix. Identity matrix is a square matrix in which the main diagonal elements contain only one and the rest of the elements are 0. For example − $\mathrm{Matrix\:=\:\begin{bmatrix}1 & 0 & 0 & 0 & 0 ewline0 & 1 & 0 & 0 & 0 ewline0 & 0 & 1 & 0 & 0ewline0 & 0 & 0 & 1 & 0ewline0 & 0 & 0 & 0 & 1\end{bmatrix}}$ Algorithm Step 1 − Create a function. Step 2 − In this function, use ...

Read More

Swift Program to Multiply two Matrices by Passing Matrix to a Function

Ankita Saini
Ankita Saini
Updated on 09-Jan-2023 298 Views

In this article, we will learn how to write a swift program to multiply two matrices by passing the matrix to a function. 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. So to multiply two matrices, we multiply the mth row of the first matrix by an nth column of the second matrix and add the products. This will create an element at the mth row and nth columns of the resultant matrix. ...

Read More
Showing 16851–16860 of 21,090 articles
Advertisements