UNIT – I
DATA STRUCTURES
INTRODUCTION AND OVERVIEW
MRS.SOWMYA JYOTHI,SDMCBM,MANGALORE
Basic Terminology
• Data are simply values or set of values.
• A data item refers to a single unit of values.
• Data items that are divided into sub-items are called group items; those that
are not called as elementary items.
• Example: Employee’s name is divided into three sub-items—first name,
middle name and last name. But employee number is treated as single item.
• An entity is something that has certain attributes or properties which may
be assigned values. The entities with similar attributes form entity set. Each
attribute has a range of values. The term information is used to refer the
processed or meaningful data.
• The way that data are organized into hierarchy of fields, records and files
reflects the relationship between attributes, entities and entity sets. That is, 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 and a file is a
collection of records of entities in the given entity set.
• Each record in a file may contain many field items, but the value in a
certain field may uniquely determine a record in the file.
• Such a field K is called a primary key, and the values k1, k2, ....kn in
such a field are called key values.
Example:
• Suppose a college maintains an inventory file to store the details of
students.
• Each records may contain the following data: Reg. No., Name, Class,
Gender, Date of Birth etc. Reg No.
• Field can serve as primary key, since each student has a unique Reg.
No.
• Records may also be classified according to length. A file can have
fixed-length records or variable-length records.
• In fixed-length records, all the records contain the same data items
with the same amount of space assigned to each data item.
• In variable-length records, file records may contain different lengths.
• For example, student records usually have variable lengths. Variable-
length records have a minimum and a maximum length.
The organization of data into fields, records and files may not be complex
enough to maintain and efficiently process certain collection of data.
For this reason, data are also organized into more complex types of
structures.
The study of data structures includes the following steps:
1) Logical or mathematical description of the structure
2) Implementation of the structure on a computer
3) Quantitative analysis of the structure, which includes determining the
amount of memory needed to store the structure and time required to
process the structure.
Data Structures
• The logical or mathematical model of a particular
organization of data is called data structure. The structure
should be simple enough to process the data effectively when
necessary.
Classification of Data Structures
Data structures are generally classified into two types-primitive and
non-primitive.
1. Primitive Data Structures are the basic data structures that
directly operate upon the machine instructions.
2. Non-primitive data structures are more complicated data
structures and are derived from primitive data structures. They
emphasize on grouping same or different data items with
relationship between each data item.
• Basic data types such as integer, real, character and Boolean are
called primitive data structures. These data types consist of
characters that cannot be divided, and hence they are called as
simple data types.
• Based on structure and arrangement of data non-primitive data
structures are further classified into linear and non-linear.
1. A data structure is said to be linear if its elements form a
sequence or linear list. In linear structure, the data is arranged in
a linear fashion although their storage may not be sequential.
• Arrays, linked lists, stacks and queues are examples of linear
data structures.
2. A data structure is said to be non-linear, if the data is not
arranged in sequence. The insertion and deletion of data is not
possible in a linear fashion. Trees and graphs are examples of non-
linear data structures.
• Arrays: The simplest type of data structure is a linear array.
• Linear array means a list of finite number n of similar data elements. If
A is the name of the array, then the array elements can be referred to as
A(1), A(2) ... A(n) or A[1], A[2], ... A[n]. The array is also called as
subscripted variable.
• A linear array A [8] consisting of numbers is pictured in following figure.
Linked Lists:
• A linked list is a linear collection of data elements, called nodes,
pointing to the next node by means of a pointer.
• It is a data structure consisting of a group of nodes which together
represent a sequence.
• Under the simplest form, each node is composed of data and a
reference (in other words, a link) to the next node in the sequence.
This structure allows for efficient insertion or removal of elements
from any position in the sequence during iteration.
Linear Data Structure
Stack:
•A stack is called last-in-first-out (LIFO) system. It is a linear
list in which insertion and deletion can take place only at
one end.
Linear Data Structure
Queue:
• A queue is also called first-in-first-out (FIFO) system.
• It is a linear list in which deletions can take place only the
“front” of the list and insertion can take place only at the “rear”
end of the list.
Non-Linear Data Structure
• Trees: There may be a hierarchical relationship between
various elements. The data structure which reflects this
relationship is called rooted tree graph or simply a tree
Non-Linear Data Structure
Graph:
• Data sometimes contain relationship between pairs of elements
which is not necessarily hierarchical in nature. A data structure
which reflects this type of relationship is called graph.
Data Structure Operations
The data stored in data structures can be processed by means of certain
operations. Different operations that can be performed include:
1) Traversing: Accessing each record exactly once so that certain items in
the record may be processed.
2) 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.
3) Inserting: Adding a record to the structure.
4) Deleting: Removing a record form the structure.
5) Sorting: Arranging the records in some logical order(alphabetically
according to NAME or numeric order of some NUMBER key.
6) Merging: Combining the records in two different sorted files into a single
sorted file.
• Example:
• Consider a list L consisting of data items – 1, 2, 3, 4, 5, 6, 7, 8,9 we can use
any of four data structures to support L – a linear list, a matrix, a tree, or a
graph.

BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI

  • 1.
    UNIT – I DATASTRUCTURES INTRODUCTION AND OVERVIEW MRS.SOWMYA JYOTHI,SDMCBM,MANGALORE
  • 2.
    Basic Terminology • Dataare simply values or set of values. • A data item refers to a single unit of values. • Data items that are divided into sub-items are called group items; those that are not called as elementary items. • Example: Employee’s name is divided into three sub-items—first name, middle name and last name. But employee number is treated as single item. • An entity is something that has certain attributes or properties which may be assigned values. The entities with similar attributes form entity set. Each attribute has a range of values. The term information is used to refer the processed or meaningful data. • The way that data are organized into hierarchy of fields, records and files reflects the relationship between attributes, entities and entity sets. That is, 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 and a file is a collection of records of entities in the given entity set.
  • 3.
    • Each recordin a file may contain many field items, but the value in a certain field may uniquely determine a record in the file. • Such a field K is called a primary key, and the values k1, k2, ....kn in such a field are called key values. Example: • Suppose a college maintains an inventory file to store the details of students. • Each records may contain the following data: Reg. No., Name, Class, Gender, Date of Birth etc. Reg No. • Field can serve as primary key, since each student has a unique Reg. No.
  • 4.
    • Records mayalso be classified according to length. A file can have fixed-length records or variable-length records. • In fixed-length records, all the records contain the same data items with the same amount of space assigned to each data item. • In variable-length records, file records may contain different lengths. • For example, student records usually have variable lengths. Variable- length records have a minimum and a maximum length.
  • 5.
    The organization ofdata into fields, records and files may not be complex enough to maintain and efficiently process certain collection of data. For this reason, data are also organized into more complex types of structures. The study of data structures includes the following steps: 1) Logical or mathematical description of the structure 2) Implementation of the structure on a computer 3) Quantitative analysis of the structure, which includes determining the amount of memory needed to store the structure and time required to process the structure.
  • 6.
    Data Structures • Thelogical or mathematical model of a particular organization of data is called data structure. The structure should be simple enough to process the data effectively when necessary.
  • 7.
    Classification of DataStructures Data structures are generally classified into two types-primitive and non-primitive. 1. Primitive Data Structures are the basic data structures that directly operate upon the machine instructions. 2. Non-primitive data structures are more complicated data structures and are derived from primitive data structures. They emphasize on grouping same or different data items with relationship between each data item. • Basic data types such as integer, real, character and Boolean are called primitive data structures. These data types consist of characters that cannot be divided, and hence they are called as simple data types.
  • 8.
    • Based onstructure and arrangement of data non-primitive data structures are further classified into linear and non-linear. 1. A data structure is said to be linear if its elements form a sequence or linear list. In linear structure, the data is arranged in a linear fashion although their storage may not be sequential. • Arrays, linked lists, stacks and queues are examples of linear data structures. 2. A data structure is said to be non-linear, if the data is not arranged in sequence. The insertion and deletion of data is not possible in a linear fashion. Trees and graphs are examples of non- linear data structures.
  • 10.
    • Arrays: Thesimplest type of data structure is a linear array. • Linear array means a list of finite number n of similar data elements. If A is the name of the array, then the array elements can be referred to as A(1), A(2) ... A(n) or A[1], A[2], ... A[n]. The array is also called as subscripted variable. • A linear array A [8] consisting of numbers is pictured in following figure.
  • 12.
    Linked Lists: • Alinked list is a linear collection of data elements, called nodes, pointing to the next node by means of a pointer. • It is a data structure consisting of a group of nodes which together represent a sequence. • Under the simplest form, each node is composed of data and a reference (in other words, a link) to the next node in the sequence. This structure allows for efficient insertion or removal of elements from any position in the sequence during iteration.
  • 14.
  • 15.
    Stack: •A stack iscalled last-in-first-out (LIFO) system. It is a linear list in which insertion and deletion can take place only at one end.
  • 16.
  • 17.
    Queue: • A queueis also called first-in-first-out (FIFO) system. • It is a linear list in which deletions can take place only the “front” of the list and insertion can take place only at the “rear” end of the list.
  • 18.
  • 19.
    • Trees: Theremay be a hierarchical relationship between various elements. The data structure which reflects this relationship is called rooted tree graph or simply a tree
  • 20.
  • 21.
    Graph: • Data sometimescontain relationship between pairs of elements which is not necessarily hierarchical in nature. A data structure which reflects this type of relationship is called graph.
  • 22.
    Data Structure Operations Thedata stored in data structures can be processed by means of certain operations. Different operations that can be performed include: 1) Traversing: Accessing each record exactly once so that certain items in the record may be processed. 2) 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. 3) Inserting: Adding a record to the structure. 4) Deleting: Removing a record form the structure. 5) Sorting: Arranging the records in some logical order(alphabetically according to NAME or numeric order of some NUMBER key. 6) Merging: Combining the records in two different sorted files into a single sorted file.
  • 23.
    • Example: • Considera list L consisting of data items – 1, 2, 3, 4, 5, 6, 7, 8,9 we can use any of four data structures to support L – a linear list, a matrix, a tree, or a graph.