ALGORITHM

In-place algorithm

An in-place algorithm is an algorithm which transforms input using no auxiliary data structure. However a small amount of extra storage space is allowed for auxiliary variables. The input is usually overwritten by the output as the algorithm executes. In-place algorithm updates input sequence only through replacement or swapping of [...]

2017-09-23T12:27:10+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: |

Detect loop in linked list

Floyd's algorithm for cycle detection is the fastest method to detect loop in linked list. Traverse linked list using two pointers. Move one pointer by one and other pointer by two. If these pointers meet at some node then there is a loop. If pointers do not meet then linked [...]

2017-02-08T22:16:05+05:30Categories: Data Structure|Tags: |

Space complexity in Data structure

Space complexity is a measure of the amount of working storage an algorithm needs. That means how much memory, in the worst case, is needed at any point in the algorithm. As with time complexity, we're mostly concerned with how the space needs grow, in big-Oh terms, as the size [...]

2017-02-08T18:53:26+05:30Categories: Data Structure|Tags: |
Go to Top