01 - Introduction 1
01 - Introduction 1
BTCS-301-18
Introduction
Jagjit kaur
Assistant Professor
Computer Science and Engineering
CGC College of Engineering, Landran
1
DATA TYPE AND DATA STRUCTURE
Data type
• Set of possible values for variables
• Operations on those values
Ex : int, float, char ……….
Data Structure
A data structure is an arrangement of data in a computer's memory or even disk
storage.
The logical and mathematical model of a particular organization of data is called
a data structure.
A data structure is a particular way of storing and organizing data in a computer
so that it can be used efficiently.
An example of several common data structures:
• arrays,
• linked lists,
• stacks,
• queues,
• trees,
• and Graph
ARRAY
STUDENT
1 Dalia Rahaman
2 Sumona
3 Mubtasim Fuad
4 Anamul Haque
5
Ibtisam Rahaman
6
Jarin
MATRICES
1 2 3 4
1 1 2 3 4
2 Here, MATRICES[3,3]=11
5 6 7 8
3 9 10 11 12
4 13 14 15 16
Array Data Structure
It can hold multiple values of a single type.
Elements are referenced by the array name and an ordinal index.
Each element is a value
Indexing begins at zero.
The array forms a contiguous list in memory.
The name of the array holds the address of the first array element.
We specify the array size at compile time, often with a named constant.
LINKED LISTS
•A linked list, or one way list, is a linear collection of data elements, called nodes,
where the linear order is given by means of pointers.
Node
Data Next
In linked list
Each node of the list contains the data item a pointer to the next node
Start
node
node
Data Next Data
3 2 A 5 LINK[3]=2, INFO[2]=A
2 LINK[2]=5, INFO[5]=N
3 M
LINK[5]=4, INFO[4]=G
4 G 7
LINK[4]=7, INFO[7]=O
5 N 4 LINK[7]=0, NULL value, So the list has ended
6
7 O 0
8
STACKS
Stacks are a special form of collection with LIFO semantics
Two methods
- add item to the top of the stack
- remove an item from the top of the stack
Like a plate stacker
QUEUES
Like a stack, a queue is also a list. However, with a queue, insertion is done at one end, while deletion
is performed at the other end
The insertion end is called rear
The deletion end is called front
Remove Insert
front rear
edges
DATA STRUCTURE OPERATIONS
The data appearing in our data structure is processed by means of certain operations.
In fact, the particular data structure that one chooses for a given situation depends
largely on the frequency with which specific operations are performed. The following
four operations play a major role:
Traversing
Accessing each record exactly once so that certain items in the record may be
processed. (This accessing or processing is sometimes called 'visiting" the records.)
Searching
Finding the location of the record with a given key value, or finding the locations of
all records, which satisfy one or more conditions.
Inserting
Adding new records to the structure.
Deleting
Removing a record from the structure.
DATA STRUCTURE OPERATIONS (CONTINUED)
The following two operations, which are used in special situations, will also be
considered:
Sorting:
Arranging the records in some logical order
Merging:
Combining the records in two different sorted files into a single sorted files
ALGORITHMS
An essential aspect to data structures is algorithms. Data structures are
implemented using algorithms.
An Algorithm is a finite step – by – step list of well defined instructions for
solving a particular problem. It is used to manipulate the data contained in
the data structures as in searching and sorting. It states explicitly how the
data will be manipulated.