FDS (Introduction - To - FDS)
FDS (Introduction - To - FDS)
Disadvantages:
• Poor utilization of the computer memory
• With the increase in the size of the data structure, the time
complexity of the structure increases.
• Memory utilization is in-effective.
Examples of Linear data structure
• Array:
– The same types of objects are stored sequentially in an array.
– The main idea of an array is that multiple data of the same
type can be stored together.
– Before storing the data in an array, the size of the array has to
be defined.
– Example
• Storing the marks for all the students in a class. Suppose there are
20 students, then the size of the array has to be mentioned as 20.
Marks of all the students can then be stored in the created array
without the need for creating separate variables for marks for every
student. Simple traversal of the array can lead to the access of the
elements.
Examples of Linear data structure
• Linked list
• The linked list is that type of data structure where separate objects
are stored sequentially.
• Every object stored in the data structure will have the data and a
reference to the next object.
• The last node of the linked list has a reference to null.
• The first element of the linked list is known as the head of the list.
• Types of linked list:
– Single Linked List
– A Double Linked List
– Circular linked List
Single linked list
Singly linked list:
1. Unidirectional, that is, it can be traversed in only one
direction from head to the last node (tail).
2. Each element in a linked list is called a node.
3. A single node contains data and a pointer to the next node
which helps in maintaining the structure of the list.
Double linked list
• Doubly linked list:
• Complex type of linked list in which a node contains a pointer to the
previous as well as the next node in the sequence.
• In a doubly linked list, a node consists of three parts: node data, pointer to
the next node in sequence (next pointer) , pointer to the previous node
(previous pointer).
Circular linked list
• A circular linked list:
• Variation of a singly linked list.
• In circular linked list the last node connects to the first node, so the link
part of the last node holds the first node's address.
• The circular linked list has no starting and ending node.
• We can traverse in any direction, i.e., either backward or forward.
Doubly Circular linked list
• Doubly circular linked list:
• The doubly circular linked list has the features of both the circular linked
list and doubly linked list.
• In Doubly circular linked list the last node is attached to the first node and
thus creates a circle.
• In doubly linked list each node holds the address of the previous node
also.
• Doubly circular linked contains three parts, i.e., two address parts and one
data part so its representation is similar to the doubly linked list.
Examples of Linear data structure
• Queue:
– First In First Out (FIFO) type of data structure
– In the case of a queue, the element that was added first is removed first.
– Both the end of the data structure is used for the insertion and the removal of
data.
– The two main operations governing the structure of the queue are enqueue,
and dequeue.
• Enqueue : Inserting an element is allowed to the collection of data
• Dequeue: Removal of elements is allowed, which is the first element in
the queue in this case.
– Queues are applied when multiple users are sharing the same resources and
they have to be served on the basis of who has come first on the server.
– Example of the queue: We can imagine a person waiting for the bus and
standing at the first position as the person that came to the queue first. This
person will be the first one who will get onto a bus, i.e. exit the queue.