4. DIFFERENT BETWEEN LINEAR AND
NONLINEAR DATA STRUCTURES
• Main difference between linear and
nonlinear data structures lie in the way they
organize data elements.
• In linear data structures, data elements are
organized sequentially and therefore they are
easy to implement in the computer’s memory.
5. *In nonlinear data structures, a data element can be
attached to several other Data elements to
represent specific relationships that exist among
them.
* Due to this nonlinear structure, they might be difficult
to be implemented in computer’s linear memory
compared to implementing linear data structures.
*Selecting one data structure type over the other
should be done carefully by considering the
relationship among the data elements that needs
to be stored.
9. STACK
A Stack is a list of elements in
which an element may be
inserted or deleted at one end
which is known as TOP of the
stack.
10. Operation performed of stack
Push: add an element in stack
Pop: remove an element in
stack
11. STACK REPRESENTATION
A stack may be represented in the memory in various
ways. There are two main ways: using a one-dimensional
array and a single linked list. Array Representation of
Stacks: First we have to allocate a memory block of
sufficient size to accommodate the full capacity of the
stack.
12. QUEUE
A queue is a linear list of element in which
insertion can be done at one end which is
known as front and deletion can be done
which is known as rear.
13. REPRESENTATION OF QUEUE
Representation of a Queue using an Array A one-
dimensional array, say Q[l ... N], can be used to
represent a queue. Figure shows an instance of such a
queue. With this representation, two pointers, namely
FRONT and REAR, are used to indicate the two ends of
the queue.
14. LINKED LIST
A Linked list is a linear collection of data
elements. It has two part one is info and
other is link part.info part gives
information and link part is address of next
node.
15. LINKED
REPRESENTATION
◦ used data structure. In a linked list,
every Linked list is a linear data
structure that includes a series of
connected nodes. Linked list can be
defined as the nodes that are randomly
stored in the memory. A node in the
linked list contains two parts, i.e., first is
the data part and second is the address
part. The last node of the list contains a
pointer to the null. After array, linked
list is the second most link contains a
connection to another link.
◦
17. TREE
In computer science ,a tree is a widely-
used data structure that emulates a
hierarchical tree structure with a set of
linked nodes.
18. TREE REPRESTATION
If you recall a linked list representation, we store each item
in a structure called Node having two or three fields
(depending on whether the list is singly or doubly ).
19. Graph
A graph data structure may also associate to each
edge some edge value such as a symbolic label or a
numeric attribute (cost, capacity, length, etc. ).