Page 19 - DCAP407_DATA_STRUCTURE
P. 19
Data Structure
cannot be deleted before FF is deleted, and similarly DD cannot be deleted before EE is deleted and so
on.
Queues
Queue is a non-primitive linear data structure, where the homogeneous data elements are stored in
sequence. In queue, data elements are inserted from one end and deleted from the other end. Hence, it
is also called as First-In First-Out (FIFO) list. Figure 1.5 shows a queue with 4 elements, where 55 is the
front element and 65 is the rear element. Elements can be added from the rear and deleted from the
front.
Figure 1.5: A Queue
Non-linear Data Structure
Non-linear data structure is a kind of data structure in which data elements are not arranged in a
sequential order. There is a hierarchical relationship between individual data items. Here, the insertion
and deletion of data is not possible in a linear fashion. Trees and graphs are examples of non-linear data
structures.
Trees and graphs are examples of non-linear data structures.
Trees
A tree is a non-linear data structure in which data is organized in branches. The data elements in tree
are arranged in a sorted order. It imposes a hierarchical structure on the data elements.
Figure 1.6 represents a tree which consists of 8 nodes. The root of the tree is the node 60 at the top. Node
29 and 44 are the successors of the node 60. The nodes 6, 4, 12 and 67 are the terminal nodes as they do
not have any successors.
Figure 1.6: A Tree
12 LOVELY PROFESSIONAL UNIVERSITY