4. NON LINEAR DATA STRUCTURE
Each element is attached to one or more elements
creating a relationship among the items.
Non-linear data structure is represent the hierarchical
relationship between the elements.
They are represented by trees and graph.
5. TREES
Tree is a nonlinear data structure used to represent
a data containing a hierarchical relationship
between the elements.
Types of tree:
Balanced binary tree
Unbalanced binary tree.
8. GRAPH
A graph is a pair of sets (V, E), where V is the set of
vertices and E is the set of edges, connecting the pairs of
vertices.
Vertex − Each node of the graph is represented as a
vertex.
Edge − Edge represents a path between two vertices or a
line between two vertices
11. OPERATIONS OF DATA STRUCTURE
1. Traversal:
Each element is processed individually.
Traversal is a process to visit all the nodes of
tree/linked list/graph.
2. Searching
3. Insertion
4.Deletion
5.Sorting
6. merging.
12. ARRAY
An array is a group of same type of data items that are
referred by a common name.
Element − Each item stored in an array is called an
element.
Index − Each location of an element in an array has a
numerical index, which is used to identify the element.
14. ARRAY REPRESENTATION
Index starts with 0.
Array length is 10 which means it can store 10
elements.
Each element can be accessed via its index. For
example, we can fetch an element at index 6 as 27.
16. WHY DOES ARRAY INDEXING START WITH 0?
int a[10];
Here a itself is a pointer which contains the memory
location of the first element of the array. Now for
accessing the first element, we will write a[0] which is
internally decoded by the compiler as *(a + 0).
In the same way, the second element can be accessed
by a[1] or *(a + 1). As a contains the address of the first
element so for accessing the second element we have to
add 1 to it. That's why here we have written *(a +1). In
an array, the index describes the offset from the first
element, i.e. the distance from the first element.
17. REPRESENTATION OF LINEAR ARRAY IN MEMORY
Let LA be a linear array that the memory of the
computer is simply a sequence of address.
Loc(LA[K])= address of the element
LA[K] of the array LA.
1000
1001
1002
1003