0
936views
Explain data structures queue, circular queue, Linked list, Array.
0
7views

1. Queue

Queue is a linear data structure in which insertion can take place at only one end called rear end and deletion can take place at other end called top end. The front and rear are two terms used to represent the two ends of the list when it is implemented as queue. Queue is also called First In First Out (FIFO) system since the first element in queue will be the first element out of the queue.

The linear arrangement of the queue always considers the elements in forward direction. In the above two algorithms, we had seen that, the pointers front and rear are always incremented as and when we delete or insert element respectively. Suppose in a queue of 10 elements front points to 4th element and rear points to 8th element as follows.

Queue 1 2 3 4 5 6 7 8 9 10
XX XX XX XX XX
front rear

2. Circular Queue

Queue 1 2 3 4 5 6 7 8 9 10
XX XX XX XX XX XX XX
front rear

Later, when we try to insert some elements, then according to the logic when REAR is N then it encounters an overflow situation. But there are some elements are left blank at the beginning part of the array. To utilize those left over spaces more efficiently, a circular fashion is implemented in queue representation. The circular fashion of queue reassigns the rear pointer with 1 if it reaches N and beginning elements are free and the process is continued for deletion also. Such queues are called Circular Queue.

A linked list is a linked representation of the ordered list. It is a linear collection of data elements termed as nodes whose linear order is given by means of link or pointer. Every node consist of two parts. The first part is called INFO, contains information of the data and second part is called LINK, contains the address of the next node in the list. A variable called START, always points to the first node of the list and the link part of the last node always contains null value. A null value in the START variable denotes that the list is empty.

4 START INFO 1 2 3 4 5 LINK
C 6
7
8
A 9
10

4. Array

It is a collection of multiple data of same data type. For example we can have an array of int type data or float type data etc.

Remember, array can have data of same type only i.e. all elements of an array have to be of same type only. We cannot have an array of combination of different data types.

We need to note two very important points about array

1. The starting index i.e. index of the first element of an array is always zero.

2. The index of last element is n-1, where n is the size of the array.

An array has static memory allocation i.e. memory size once allocated for an array cannot be changed