Git Product home page Git Product logo

dsa's Introduction

Data Structure & Algorithm

Array

Array is a static linear data structure which stores similar type of data item stored at contiguous memory location.

Advantages:

  • It allows random access to elements.
  • It is fast to access.
  • It is easy to implement.

Disadvantages:

  • It's size is fixed.
  • Insertion and deletion is difficult to implement because it stores data in contiguous memory location and to do this we have to shift all the elements.

Real Life Examples:

  • The contact list in our phone represents the feature of array because when we add a new contact all the contacts shifts and the same thing happens when we delete a contact.

Linked List

Linked List is a dynamic linear data structure which stores similar type of data items stored at random memory location and each data is stored in a shell which is known as node which has a value bucket and a pointer bucket, value bucket stores value and the pointer bucket stores the address of the next node. That's why they are called linked list

Advantages:

  • It has dynamic size.
  • We can easily insert and delete elements in it.

Disadvantages:

  • Random access of element is not allowed.
  • Extra memory required for pointer.

Real Life Examples-

  • Image viewer uses linked list to link images with two buttons previous and next, with which we can move forward or backward.

Stack

Stack is a linear data structure which follows a perticular order in which operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). It can be implemented by both Array or Linked List. Mainly there are three operations performed in the stack.

  • Push(For adding item into the stack.)
  • Pop(For removing the item from the stack.)
  • Peek or Top(Shows what is the top most item.)

Advantages:

  • It is easy to implement.
  • It can be implemented by array or linked list.
  • In the implementation through array there is no need of pointer which saves space.
  • In the implementation through linked list the stack can grow or shrink at the runtime.

Disadvantages:

  • It is not dynamic.
  • In implementation through array, we can't increase or decrease the size of stack at the runtime.
  • In implementation through linked list, there is a need of extra memory due to pointers.

Real Life Examples:

  • In canteen the plates are stacked over one another. The plate which is at top is firstly removed and the last plate which was placed very firstly can remain in the stack for the longest time.

Queue

Queue is a linear data structure which follows a particular order in which operations are performed. The order is FIFO(First In First Out).Mainly there are four operations performed on the queue.

  • Enqueue(For adding item into the queue.)
  • Dequeue(For removing item from the queue.)
  • Front(Show the front item of the queue.)
  • Rear(Show the last item of the queue.)

Advantages:

  • It is easy to implement.
  • Implemented using linked list.

Disadvantages:

  • It is static, not dynamic.

Real Life Examples:

  • The queue of people at ticket counter follows the same principal, the first person is served first.

Graph

Graph is an non-linear data structure consistings of finite set of nodes(vertices) and edges. The edges are the arcs or line which join two nodes or vertices together

Advantages:

Disadvantages:

Real Life Examples:

  • The network of path in a city which connect one city from another.

Tree

Tree is an non-linear data structure which is also a multilevel data structure with a hierarchical relationship among its nodes. The bottom most node in the hierarchy is known as leaf node and the topmost is known as root node. It is based on parent-child relationship among the nodes. Each node in the tree can have more than one children except the leaf node.

Advantages:

Disadvanteges:

Real Life Examples:

Trie

Tree is an non-linear data structure which is also a multilevel data structure with a hierarchical relationship among its nodes. The bottom most node in the hierarchy is known as leaf node and the topmost is known as root node. It is based on parent-child relationship among the nodes. Each node in the tree can have more than one children except the leaf node.

Advantages:

Disadvanteges:

Real Life Examples:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.