Data Structure

Graph Representations | Data Structure

Introduction A graph is a pictorial representation of a set of objects where some pairs of objects are connected by links. The interconnected objects are represented by points termed as Vertices, and the links that connect the vertices are called Edges. It consists of following two components: A finite set of [...]

2024-04-24T22:26:05+05:30Categories: Data Structure|Tags: |

Searching Algorithm

To search an element in a given array, it can be done in two ways Linear search and Binary search. Linear Search Given an array arr[] of n elements, to search for a given element follow below steps :- Start from the leftmost element of arr[] and one by one [...]

2017-04-15T07:58:23+05:30Categories: Data Structure|Tags: |

Algorithm to merge sorted arrays

Assume, that both arrays are sorted in ascending order and we want resulting array to maintain the same order. Algorithm to merge two arrays A[0..m-1] and B[0..n-1] into an array C[0..m+n-1] is as following: Introduce read-indices i, j to traverse arrays A and B, accordingly. Introduce write-index k to store [...]

2017-04-15T07:01:53+05:30Categories: Data Structure|Tags: |

Sorting algorithm

Sorting is a process of arranging items in ascending or descending order. This process can be implemented via many different algorithms. Following is the list of sorting algorithms : Bubble Sort Selection Sort Count Sort Insertion Sort Merge Sort Quicksort Heap Sort Time complexity of sorting algorithm   [...]

2018-04-03T20:46:37+05:30Categories: Data Structure|Tags: |

Dynamic programming approaches

Introduction Dynamic programming (DP) is a very powerful technique to solve a particular class of problems. The idea is very simple, if we have solved a problem with the given input, then save the result for future reference, so as to avoid solving the same problem again.  If the given [...]

2024-05-16T13:58:48+05:30Categories: Data Structure|Tags: |

Next greater element in an array

Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element on the right side of x in array. Elements for which no greater element exist, consider next greater element as -1. Examples: a) For any [...]

2017-07-15T14:01:29+05:30Categories: Data Structure|Tags: |

Binary Heap

Binary Heap A binary heap is a complete binary tree which satisfies the heap ordering property. The ordering can be one of two types: Min-heap property: Value of each node is greater than or equal to the value of its parent, with the minimum-value element at the root. Min [...]

2018-12-31T12:05:10+05:30Categories: Data Structure|
Go to Top