BON SECOURS COLLEGE FOR
WOMEN,THANJAVUR
DEPARTMENT OF
INFORMATION TECHNOLOGY
CLASS: III B.SC-IT
DATE: 02/07/2022
TIME: 10.00 AM to 10.45 AM
&
11.00 Am to 11.45 AM
SUBJECT: DATA STRUCTURES &
ALGORITHMS
PREPARED BY
Dr.G.AMBIKA
MCA.,M.Phil.,Ph.D.,
Assistant professor,
Department of Information Technology,
Bon secours college for women,
Thanjavur.
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.
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.
STRUCTURE OF THE TREE
STRUCTURE OF THE TREE
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
GRAPH
V = {a, b, c, d, e}
E = {ab, ac, bd, cd, de}
TYPES OF GRAPH
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.
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.
ARRAY REPRESENTATION
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.
ARRAY REPRESENTATION
Fetching element:
Array[0]=35, array[1]=33, array[2]=42,array[3]=10,
Array[4]=14,Array[5]=19,Array[6]=27,Array[7]=44,Arra
y[8]=26,Array[9]=31.
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.
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
Data Structure.pptx

Data Structure.pptx

  • 1.
    BON SECOURS COLLEGEFOR WOMEN,THANJAVUR DEPARTMENT OF INFORMATION TECHNOLOGY
  • 2.
    CLASS: III B.SC-IT DATE:02/07/2022 TIME: 10.00 AM to 10.45 AM & 11.00 Am to 11.45 AM SUBJECT: DATA STRUCTURES & ALGORITHMS
  • 3.
    PREPARED BY Dr.G.AMBIKA MCA.,M.Phil.,Ph.D., Assistant professor, Departmentof Information Technology, Bon secours college for women, Thanjavur.
  • 4.
    NON LINEAR DATASTRUCTURE  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 isa nonlinear data structure used to represent a data containing a hierarchical relationship between the elements.  Types of tree: Balanced binary tree Unbalanced binary tree.
  • 6.
  • 7.
  • 8.
    GRAPH  A graphis 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
  • 9.
    GRAPH V = {a,b, c, d, e} E = {ab, ac, bd, cd, de}
  • 10.
  • 11.
    OPERATIONS OF DATASTRUCTURE  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 arrayis 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.
  • 13.
  • 14.
    ARRAY REPRESENTATION  Indexstarts 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.
  • 15.
    ARRAY REPRESENTATION Fetching element: Array[0]=35,array[1]=33, array[2]=42,array[3]=10, Array[4]=14,Array[5]=19,Array[6]=27,Array[7]=44,Arra y[8]=26,Array[9]=31.
  • 16.
    WHY DOES ARRAYINDEXING 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 LINEARARRAY 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