Saturday, 22 July 2017

Data Structures types | Array | Stack | Queue | Linked list | Tree | Graph

Types Of Data Structure



Array

array_image

In computer programming, a group of homogeneous elements of a specific data type is known as an array , one of the simplest data structures. Arrays hold a series of data elements, usually of the same size and data type. An array element is accessed by writing the name of the array followed by the position (index) in square brackets. Most programming languages have a built-in array data type.


array_image_missing

Linked List

In computer science, a linked list is one of the fundamental dynamic data structures used in computer programming. It consists of a sequence of nodes, each containing arbitrary data fields and one or two references ("links") pointing to the next and/or previous nodes.

linked_list_image_missing

Some common examples of a linked list...

  • Hash tables use linked lists for collission resolution..
  • Any "File Requester" dialog uses a linked list.
  • Binary Trees , Stacks and Queues can be implemented with a doubly linked list.
  • Relational Databases (e.g. Microsoft Access).

  • A linked list is a self-referential data type because it contains a link to another data of the same type. Linked lists permit insertion and removal of nodes at any point in the list in constant time, but do not allow random access.

    linked_list_image_missing

    Stack

    stack_image_missing

    A stack is a linear Structure in which item may be added or removed only at one end. There are certain frequent situations in computer science when one wants to restrict insertions and deletions so that they can take place only at the beginning or end of the list, not in the middle.

    A stack is a list of elements in which an elements may be inserted or deleted only at one end, called the Top. This means, in particular, the elements are removed from a stack in the reverse order of that which they are inserted in to the stack. The stack also called "last-in first -out (LIFO) " list.

    Primary operations defined on a stack:

    PUSH : Add an element at the top of the list.

    POP : Remove an element from the top of the list.

    Example :

    Practical daily life : A pile of heavy books kept in a vertical box,dishes kept one on top of another.

    In computer world : In processing of subroutine calls and returns , there is an explicit use of stack of return addresses.


    Queue

    A queue is a linear list of elements in which deletions can take place only at one end, called the " front " and insertion can take place only at the other end, called " rear ". The term " front " and " rear " are used in describing a linear list only when it is implemented as a queue.


    queue_image_missing

    Queues are also called " first-in first-out " (FIFO) list. Since the first element in a queue will be the first element out of the queue. In other words, the order in which elements enter in a queue is the order in which they leave.

    queue_image_missing

    The real life example: the people waiting in a line at Railway ticket Counter form a queue, where the first person in a line is the first person to be waited on. An important example of a queue in computer science occurs in time sharing system, in which programs with the same priority form a queue while waiting to be executed.

    Tree image missing

    Graph

    Graph structures represents hierarchial relationship between individual data elements. Graphs are nothing but trees with certain restrictions removed.A graph consists of a set of nodes (or Vertices ) and a set of arc (or edge ).


    Tree

    A tree is hierarchical collection of nodes. One of the nodes, known as the root, is at the top of the hierarchy. Each node can have at most one link coming into it. The node where the link originates is called the parent node. The root node has no parent. The links leaving a node (any number of links are allowed) point to child nodes. Trees are recursive structures. Each child node is itself the root of a sub tree. At the bottom of the tree are leaf nodes, which have no children.


    Share this

    0 Comment to "Data Structures types | Array | Stack | Queue | Linked list | Tree | Graph"

    Post a Comment