Array is a static linear data structure which stores similar type of data item stored at contiguous memory location.
- It allows random access to elements.
- It is fast to access.
- It is easy to implement.
- 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.
- 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 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
- It has dynamic size.
- We can easily insert and delete elements in it.
- Random access of element is not allowed.
- Extra memory required for pointer.
- Image viewer uses linked list to link images with two buttons previous and next, with which we can move forward or backward.
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.)
- 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.
- 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.
- 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 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.)
- It is easy to implement.
- Implemented using linked list.
- It is static, not dynamic.
- The queue of people at ticket counter follows the same principal, the first person is served first.
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
- The network of path in a city which connect one city from another.
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.
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.