Analysis of Algorithms Articles

Found 161 articles

Matrix multiplication algorithm

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 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

Operations on an Array in Data Structures

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 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#include #include using namespace std; main(){    vector arr;    //insert elements   ...

Read More

Binary Tree Traversals in Data Structures

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 1K+ Views

In this section we will see different traversal algorithms to traverse keys present in binary search tree. These traversals are Inorder traversal, Preorder traversal, Postorder traversal and the level order traversal.Suppose we have one tree like this −The Inorder traversal sequence will be like − 5 8 10 15 16 20 23The Preorder traversal sequence will be like − 10 5 8 16 15 20 23The Postorder traversal sequence will be like − 8 5 15 23 20 16 10The Level-order traversal sequence will be like − 10, 5, 16, 8, 15, 20, 23AlgorithminorderTraverse(root): Begin    if root is not ...

Read More

Binomial Distribution in Data Structures

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 506 Views

The Binomial Distribution is a discrete probability distribution Pp(n | N) of obtaining n successes out of N Bernoulli trails (having two possible outcomes labeled by x = 0 and x = 1. The x = 1 is success, and x = 0 is failure. Success occurs with probability p, and failure occurs with probability q as q = 1 – p.) So the binomial distribution can be written as$$P_{p}\lgroup n\:\arrowvert\ N\rgroup=\left(\begin{array}{c}N\ n\end{array}\right) p^{n}\lgroup1-p\rgroup^{N-n}$$Example#include #include using namespace std; int main(){    const int nrolls = 10000; // number of rolls    const int nstars = 100; // maximum ...

Read More

Convex Hull Example in Data Structures

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 2K+ Views

Here we will see one example on convex hull. Suppose we have a set of points. We have to make a polygon by taking less amount of points, that will cover all given points. In this section we will see the Jarvis March algorithm to get the convex hull.Jarvis March algorithm is used to detect the corner points of a convex hull from a given set of data points.Starting from left most point of the data set, we keep the points in the convex hull by anti-clockwise rotation. From a current point, we can choose the next point by checking ...

Read More

Algorithms and Complexities

Monica Mona
Monica Mona
Updated on 01-Nov-2023 45K+ Views

AlgorithmAn algorithm is a finite set of instructions, those if followed, accomplishes a particular task. It is not language specific, we can use any language and symbols to represent instructions.The criteria of an algorithmInput: Zero or more inputs are externally supplied to the algorithm.Output: At least one output is produced by an algorithm.Definiteness: Each instruction is clear and unambiguous.Finiteness: In an algorithm, it will be terminated after a finite number of steps for all different cases.Effectiveness: Each instruction must be very basic, so the purpose of those instructions must be very clear to us.Analysis of algorithmsAlgorithm analysis is an important part ...

Read More

Can we use Simple Queue instead of Priority queue to implement Dijkstra’s Algorithm?

Sonal Meenu Singh
Sonal Meenu Singh
Updated on 22-Feb-2023 3K+ Views

Introduction Dijkstra’s Algorithm is used to find the shortest possible distance between two objects. To implement this algorithm we mostly use Priority Queue. In this tutorial, we will find the answer to whether can we use a simple queue to implement Dijkstra’s algorithm instead of a Priority Queue. What is a Priority Queue and A Queue? A queue is a linear array of data. It represents the Queue of real life. A simple Queue uses FIFO (First In First Out) approach for its deQueue and enQueue operations. A priority Queue is a type of Queue that deQueue its elements with ...

Read More

Difference Between Quick Sort and Merge Sort

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 21-Feb-2023 6K+ Views

The task of arranging the elements of an array in a particular order is referred to as sorting. The sorting of an array or a list is mainly done to make the searching easier. There are several types of sorting algorithms, but in this article, we will concentrate on quick sort and merge sort. Both quick sort and merge sort algorithms are based on the divide-and-conquer sorting algorithms, hence they work almost in a similar way. Read this article to learn more about quick sort and merge sort and how these sorting techniques are different from each other. What is ...

Read More

Difference between Deterministic and Non-deterministic Algorithms

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 21-Feb-2023 25K+ Views

In the context of programming, an Algorithm is a set of well-defined instructions in sequence to perform a particular task and achieve the desired output. Here we say "a set of defined instructions" which means that somewhere the user knows the outcome of those instructions if they get executed in the expected manner. On the basis of the knowledge about outcome of the instructions, there are two types of algorithms namely, Deterministic and Non-deterministic Algorithms. Read this article to learn more about deterministic and non-deterministic algorithms and how they are different from each other. What is Deterministic Algorithm? A deterministic ...

Read More

Difference Between Bubble Sort and Selection Sort

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 20-Feb-2023 15K+ Views

The task of arranging elements of an array in a particular order is referred to as sorting. The sorting of an array or a list is mainly done to make the searching easier. There are two types of sorting algorithms namely, Bubble Sort and Selection Sort. Bubble sort performs sorting of data by exchanging the elements, while the selection sort performs sorting of data by selecting the elements. Read this article to learn more about bubble sort and selection sort and how these two sorting techniques are different from each other. What is Bubble Sort? Bubble sort is a simple ...

Read More
Showing 1–10 of 161 articles
« Prev 1 2 3 4 5 17 Next »
Advertisements