The document is an introduction to data structures presented by M. Priyavani. It defines key terms like data, records, fields and files. It classifies data structures as primitive (integer, real, character, boolean) and non-primitive (linear like arrays and linked lists, and non-linear like trees and graphs). It describes common operations on data structures like traversing, searching, inserting and deleting. It also introduces algorithms, complexity analysis, and discusses the time-space tradeoff in choosing appropriate data structures.
2. Welcome
Dear Students!!!
Assistant Professor,
Department of Computer Applications
(PG),
V.V.Vanniapermal College for Women,
Virudhunagar – 626001.
Mrs.M.Priyavani,MCA,DCHN,M.Phil.,
M.Priyavani,MCA,DCHN,M.Phil.,
V.V.V.College,Virudhunagar.
11. M.Priyavani,MCA,DCHN,M.Phil.,
V.V.V.College,Virudhunagar.
The way the data are
organized into the
hierarchy of fields,
records and files
reflect the
relationship between
attributes, entities
and entity sets.
• A field is a single elementary
unit of information
representing an attribute of
an entity.
• A record is a collection of
field values of a given entity.
• A file is a collection of
records.
15. Data Structure - Definition
M.Priyavani,MCA,DCHN,M.Phil.,
V.V.V.College,Virudhunagar.
The logical or mathematical model of a particular
organization of data is called data structure.
16. M.Priyavani,MCA,DCHN,M.Phil.,
V.V.V.College,Virudhunagar.
It must be rich
enough in structure
to mirror the actual
relationships of the
data in the real
world.
The structure should
be simple enough
that one can
effectively process
the data when
necessary.
Choice of a PARTICULAR data model depends on these considerations…
1
2
23. The data appearing in our data structures are processed by means
of certain operations.
There are four operations:
• Traversing
• Searching
• Inserting
• Deleting
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
24. Traversing
• Accessing each record exactly once so that certain or all items in the
record may be processed.
1 2 3 4 5 6 7 8
Array
elements:
Processing
Output
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
1
2
3
4
Accessing 1st
element
Accessing 2nd
element
Accessing 3rd
element
Accessing 4th
element M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
25. Searching
• Finding the location of the record with a given key value, or finding
the location of all records which satisfy one or more conditions.
12 43 87 34 51 36 72 48
Array
elements:
Searching
Output
12 43 87 34 51 36 72 48 No Match
Key value
34
Comparing 1st
element
Accessing 2nd
element
Accessing 3rd
element
Accessing 4th
element
12 43 87 34 51 36 72 48
12 43 87 34 51 36 72 48
12 43 87 34 51 36 72 48
No Match
No Match
Matching
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
26. Inserting
• Adding a new record to the structure
12 43 87 34 51 36 72 48
Existing
elements:
12 43 87 34 51 36 72
Insert value
66
Moving last
element
Moving next
element
Moving next
element
Moving next
element
12 43 87 34 51 36 72
12 43 87 34 51 36 72
12 43 87 34 51 36 72
4
Position
48
48
48
48
Moving next
element
12 43 87 34 51 36 72 48
Inserting as 4th
element
12 43 87 66 34 51 36 72 48M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
27. Deleting
• Removing a record from the structure
12 43 87 66 34 51 36 72
Existing
elements:
12 43 87 66 34 36 72
Removing the
element
Moving next
element
Moving next
element
Moving last
element
12 43 87 66 34 36 72
12 43 87 66 34 36 72
12 43 87 66 34 36 72 48
6
Position
48
48
48
Deleting Gap 12 43 87 66 34 36 72 48
48
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
28. Other two operations used in special situations…
• Sorting
• Arranging the records in some logical order.
• Merging
• Combining the records in two different sorted files into a
single sorted file.
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
29. Abstract Data Types
• Refers to a set of data values and associated operations.
• Consists of a set of definitions that allow us to use the functions while
hiding the implementation.
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
31. 2 different parts of the ADT model
• Data are entered, accessed, modified and deleted
through the external application programming
interface.
• This interface can access only the public functions.
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
33. ALGORITHM
• Is a well defined list of steps for solving a particular problem.
• Example problem: Adding 2 numbers.
• Algorithm:
1. Read first value from user and assume it to be A.
2. Read second value from user and assume it to be B.
3. Add the 2 values into another variable. (C=A+B)
4. Show the added value to the user.
• The time and space it uses are 2 major measures of the efficiency of
an algorithm.
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
34. ALGORITHM
• The complexity of an algorithm is the function which gives the
running time and/or space in terms of the input size.
• For example, running time of a sorting algorithm is more when
number of elements is more.
• The storage space also increases with the number of input
values.
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
35. SORTING
Linear Search Binary Search
Given Elements:
23
54
12
87
55
Element to be searched: 87
Comparisons Needed = 4
Element to be searched: 22
Comparisons needed = 5
If number of elements is 1000?
Complexity of Linear Search algorithm:
C(n) = n/2
Given Elements:
12
23
54
55
87
Element to be searched: 87
Comparisons Needed = 3
Element to be searched: 22
Comparisons needed = 2
If number of elements is 1000?
Complexity of Binary Search algorithm:
C(n) = Log2n
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
36. WHICH DATA STRUCTURE TO USE?
• The choice of data structure depends on many things including
• type of data
&
• frequency with which various data operations are applied.
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.
37. TIME-SPACE TRADEOFF
• The choice of data structure
involves a time-space tradeoff.
• By increasing the amount of
space for storing the data, one
may be able to reduce the time
needed for processing the data
or vice-versa.
M.Priyavani,MCA,DCHN,M.Phil., V.V.V.College,Virudhunagar.