Data Structure Algorithms Articles

Page 24 of 24

Operations on an Array in Data Structures

Arnab Chakraborty
Arnab Chakraborty
Updated on 27-Aug-2019 1K+ Views

Here we will see some basic operations of array data structure. These operations are −TraverseInsertionDeletionSearchUpdateThe traverse is scanning all elements of an array. The insert operation is adding some elements at given position in an array, delete is deleting element from an array and update the respective positions of other elements after deleting. The searching is to find some element that is present in an array, and update is updating the value of element at given position. Let us see one C++ example code to get better idea.Example Live Demo#include #include using namespace std; main(){    vector arr;    //insert elements ...

Read More

Matrix multiplication algorithm

Arnab Chakraborty
Arnab Chakraborty
Updated on 27-Aug-2019 27K+ Views

In this section we will see how to multiply two matrices. The matrix multiplication can only be performed, if it satisfies this condition. Suppose two matrices are A and B, and their dimensions are A (m x n) and B (p x q) the resultant matrix can be found if and only if n = p. Then the order of the resultant matrix C will be (m x q).AlgorithmmatrixMultiply(A, B): Assume dimension of A is (m x n), dimension of B is (p x q) Begin    if n is not same as p, then exit    otherwise define C ...

Read More

Step Count Method in Algorithm

Arnab Chakraborty
Arnab Chakraborty
Updated on 27-Aug-2019 11K+ Views

The step count method is one of the method to analyze the algorithm. In this method, we count number of times one instruction is executing. From that we will try to find the complexity of the algorithm.Suppose we have one algorithm to perform sequential search. Suppose each instruction will take c1, c2, …. amount of time to execute, then we will try to find out the time complexity of this algorithmAlgorithmNumber of timesCostseqSearch(arr, n, key)i := 0while i < n, do   if arr[i] = key, then      break   end ifdonereturn i1n+1n0/11c1c2c3c4c5Now if we add the cost by multiplying the ...

Read More

Dynamic Programming in JavaScript

Samual Sam
Samual Sam
Updated on 30-Jul-2019 3K+ Views

Dynamic programming breaks down the problem into smaller and yet smaller possible sub-problems. These sub-problems are not solved independently. Rather, results of these smaller sub-problems are remembered and used for similar or overlapping sub-problems. Dynamic programming is used where we have problems, which can be divided into similar sub-problems so that their results can be re-used. Mostly, these algorithms are used for optimization. Before solving the in-hand sub-problem, the dynamic algorithm will try to examine the results of the previously solved sub-problems. The solutions of sub-problems are combined in order to achieve the best solution. For a problem to be ...

Read More
Showing 231–234 of 234 articles
« Prev 1 20 21 22 23 24 Next »
Advertisements