Found 216 Articles for Analysis of Algorithms

Abstract Data Type in Data Structures

Arnab Chakraborty
Updated on 05-Oct-2023 01:03:30

27K+ Views

The Data Type is basically a type of data that can be used in different computer program. It signifies the type like integer, float etc, the space like integer will take 4-bytes, character will take 1-byte of space etc.The abstract datatype is special kind of datatype, whose behavior is defined by a set of values and set of operations. The keyword “Abstract” is used as we can use these datatypes, we can perform different operations. But how those operations are working that is totally hidden from the user. The ADT is made of with primitive datatypes, but operation logics are ... Read More

Applications of Stack in Data Structure

Arnab Chakraborty
Updated on 27-Aug-2019 07:15:14

3K+ Views

The Stack is Last In First Out (LIFO) data structure. This data structure has some important applications in different aspect. These are like below −Expression Handling −Infix to Postfix or Infix to Prefix Conversion −The stack can be used to convert some infix expression into its postfix equivalent, or prefix equivalent. These postfix or prefix notations are used in computers to express some expressions. These expressions are not so much familiar to the infix expression, but they have some great advantages also. We do not need to maintain operator ordering, and parenthesis.Postfix or Prefix Evaluation −After converting into prefix or ... Read More

Principles of Recursion in Data Structures

Arnab Chakraborty
Updated on 26-Aug-2019 11:24:06

3K+ Views

The recursion is a process by which a function calls itself. We use recursion to solve bigger problem into smaller sub-problems. One thing we have to keep in mind, that if each sub-problem is following same kind of patterns, then only we can use the recursive approach.A recursive function has two different parts. The base case and the recursive case. The base case is used to terminate the task of recurring. If base case is not defined, then the function will recur infinite number of times (Theoretically).In computer program, when we call one function, the value of the program counter ... Read More

Huffman Coding

Arnab Chakraborty
Updated on 05-Aug-2019 07:44:26

7K+ Views

Huffman coding is lossless data compression algorithm. In this algorithm a variable-length code is assigned to input different characters. The code length is related with how frequently characters are used. Most frequent characters have smallest codes, and longer codes for least frequent characters.There are mainly two parts. First one to create Huffman tree, and another one to traverse the tree to find codes.For an example, consider some strings “YYYZXXYYX”, the frequency of character Y is larger than X and the character Z has least frequency. So the length of code for Y is smaller than X, and code for X ... Read More

All-Pairs Shortest Paths

Arnab Chakraborty
Updated on 07-Nov-2023 03:20:32

57K+ Views

The all pair shortest path algorithm is also known as Floyd-Warshall algorithm is used to find all pair shortest path problem from a given weighted graph. As a result of this algorithm, it will generate a matrix, which will represent the minimum distance from any node to all other nodes in the graph.At first the output matrix is same as given cost matrix of the graph. After that the output matrix will be updated with all vertices k as the intermediate vertex.The time complexity of this algorithm is O(V3), here V is the number of vertices in the graph.Input − ... Read More

Single-Source Shortest Paths, Arbitrary Weights

Arnab Chakraborty
Updated on 02-Jul-2020 12:59:46

9K+ Views

The single source shortest path algorithm (for arbitrary weight positive or negative) is also known Bellman-Ford algorithm is used to find minimum distance from source vertex to any other vertex. The main difference between this algorithm with Dijkstra’s algorithm is, in Dijkstra’s algorithm we cannot handle the negative weight, but here we can handle it easily.Bellman-Ford algorithm finds the distance in bottom up manner. At first it finds those distances which have only one edge in the path. After that increase the path length to find all possible solutions.Input − The cost matrix of the graph:0 6 ∞ 7 ∞ ∞ ... Read More

Single-Source Shortest Paths, Nonnegative Weights

Arnab Chakraborty
Updated on 02-Jul-2020 13:00:42

570 Views

The single source shortest path algorithm (for non-negative weight) is also known Dijkstra algorithm. There is a given graph G(V, E) with its adjacency matrix representation, and a source vertex is also provided. Dijkstra’s algorithm to find the minimum shortest path between source vertex to any other vertex of the graph G.From starting node to any other node, find the smallest distances. In this problem the graph is represented using the adjacency matrix. (Cost matrix and adjacency matrix is similar for this purpose).Input − The adjacency matrix −0 3 6 ∞ ∞ ∞ ∞ 3 0 2 1 ∞ ∞ ... Read More

Prim’s (Minimum Spanning Tree) MST Algorithm

Arnab Chakraborty
Updated on 02-Jul-2020 13:02:11

869 Views

There is a connected graph G(V, E) and the weight or cost for every edge is given. Prim’s Algorithm will find the minimum spanning tree from the graph G.It is growing tree approach. This algorithm needs a seed value to start the tree. The seed vertex is grown to form the whole tree.The problem will be solved using two sets. One set holds the nodes that are already selected, and another set holds the item that are not considered yet. From the seed vertex, it takes adjacent vertices, based on minimum edge cost, thus it grows the tree by taking ... Read More

Kruskal’s (Minimum Spanning Tree) MST Algorithm

Arnab Chakraborty
Updated on 11-Jun-2020 19:45:15

924 Views

There is a connected graph G(V, E) and the weight or cost for every edge is given. Kruskal’s algorithm will find the minimum spanning tree using the graph and the cost.It is merge tree approach. Initially there are different trees, this algorithm will merge them by taking those edges whose cost is minimum, and form a single tree.In this problem, all of the edges are listed, and sorted based on their cost. From the list, edges with minimum costs are taken out and added in the tree, and every there is a check whether the edge forming cycle or not, ... Read More

Breadth First Search or BFS for a Graph

Arnab Chakraborty
Updated on 05-Aug-2019 06:55:55

2K+ Views

The Breadth First Search (BFS) traversal is an algorithm, which is used to visit all of the nodes of a given graph. In this traversal algorithm one node is selected and then all of the adjacent nodes are visited one by one. After completing all of the adjacent vertices, it moves further to check another vertices and checks its adjacent vertices again.To implement this algorithm, we need to use the Queue data structure. All the adjacent vertices are added into the queue, when all adjacent vertices are completed, one item is removed from the queue and start traversing through that ... Read More

Advertisements