Skip to main content

Posts

Showing posts with the label data structure.

Sorting Techniques In Data Structure

      ⇰  SORTING :- In our day-to-day life there are many things that we need to search for , like any page in book, phone number in directory, any record in database etc.  All these  would have been mixed up if these data was kept unordered and unsorted. For this purpose fortunately the concept of  sorting  is introduced. Sorting makes easier for everyone to arrange any data in an order, hence searching becomes easier. Means s orting  arranges data in a sequence or in order which makes searching easier. ⇾ After applying the sorting technique, If the contents do not change the sequence of similar content in which they appear, it is called stable sorting technique. ⇾ After applying the sorting technique, if  the contents do change the sequence of similar content in which they appear, it is called unstable sorting technique.       ⇰   SORTING ORDERS :- ⇾ Basically all sorting techniques sorts the given data in following orders :-     i > Increasing Order :- The or

Shell Sort In data Structure

    ⇰  SHELL SORT :-  Shell sort is also a type of sorting technique.   Shell sort is a highly efficient sorting technique. It is    mainly a variation of insertion sort.   This technique takes short shifts , avoids large shifts as in insertion sort.  This technique uses insertion sort on a large number of elements, first this technique sorts more  widely spaced elements then sorts the less widely spaced elements. This spacing is known as gap or intervals.     The shell sort is named after its developer Donald Shell. This sorting technique works by comparing list elements that are seperated by a specific distance called gap, until the element compared with the current gap are in order, and then divides gap and the process contineous. When the gap is reached to 0 and changes are not possible, then the list is sorted.  EXAMPLE :-               ⇰  ALGORITHM OF SHELL SORT :-  Variable Used :- array= list of element,                  size= number of element. gap, swap, i

Insertion Sort In Data Structure

    ⇰  INSERTION SORT :- Insertion sort  is one of the simplest method to sort an array.  This is an in-place comparison-based sorting algorithm.  The array is searched sequentially and unsorted items are moved left or right side according to order we want to sort. This sorting algorithm is not suitable for large data. Its average and worst case complexity is  Ο(n 2 ), where n  is the number of items in an array.       An example of insertion sort occurs in everyday life is while playing cards. Ones hand extract the card, and then shift the remaining cards and then insert the extracted card in the correct place. This process is repeated until all the cards are in the correct position or in correct sequence.   FOR EXAMPLE :-     Let us take an unsorted array:-                 3 7 4 1 8 2 now the insertion sort technique compare the 1st element of array to 2nd element, if sequence or order is not correct then corrects it.                 3 7 4 1 8 2 Comparing the 1s

Graph Traversal In Data Structure

  ⇰ GRAPH TRAVERSAL :-  Sometimes it is required to examine all the vertex in a graph in some systematic order, as in the case of  binary tree traversal  , where we use preorder, postorder or inorder to examine the vertices. For that we use graph traversal.  Graph traversal is a technique used to search vertex in a graph to perform any operation there. The graph traversal is also used to conclude the order of vertices visited in the searching process. A graph traversal finds the edges without creating loops. That means using graph traversal techniques we can visit all the vertices of the graph without any looping path.    ⇰ TYPE OF GRAPH TRAVERSAL :-  There are following two types of graph traversal techniques :-   i >  Depth First Search ( DFS).  ii >  Breadth First Search ( BFS).  i >  Depth First Search ( DFS) :- Depth first search of graph traversal is similar to depth first search of tree traversal. This  algorithm traverses a graph in a depthward motio

Graph In Data Structure

       ⇰ GRAPH A graph is a non-linear data structure. It  is a pictorial representation of a set of objects where some pairs of objects are connected by links. It  consisting of nodes and edges.  The nodes are sometimes also referred to as vertices and the edges are links that connect any two nodes or vertices in the graph.  Therefore we can say a graph is a collection of nodes and edges in which two nodes are coonected with edges . It can be seen as a cyclic tree, where the vertices maintain any other relationship among them instead of having parent child relationship as in tree.  Generally a graph 'G' is represented as G(V,E) , where V represents set of vertices of G  and E represents  set of edges or links of G. following is  a graph with five vertices and seven edges.  Graph with 5 vertices and 7 edges We can define the above graph as G(V,E). where V={A, B, C, D, E} and E={ (A,B), (A,C), (A,D), (B,D), (C,D), (B,E), (D,E) }.     ⇰  APPLICATIONS O