CSE 134: Data Structure Lecture #1: Mohammad Reduanul Haque
CSE 134: Data Structure Lecture #1: Mohammad Reduanul Haque
Lecture #1
Introduction
Text Book:
1. Data Structures & Algorithm Analysis in C++, 2nd edition, by Mark Allen
Weiss
2. P.S. Deshpande and O.G. Kakde, C and Data Structures, Charles Rive
Media, 2004
Data
Data are information in raw or unorganized form (such as alphabets, numbers,
or symbols) that refer to, or represent, conditions, ideas, or objects. Data are
values or set of values. A data item refers to a single unit of values.
Data items that are divided into sub items are group items; those that are not
are called elementary items.
For example, a student’s name may be divided into three sub items – [first
name, middle name and last name] but the ID of a student would normally be
treated as a single item.
In the above example ( ID, Age, Gender, First, Middle, Last, Street, Area ) are
elementary data items, whereas (Name, Address ) are group data items.
Example:
Attributes: Name Age Gender Social Society number
Values: Hamza 20 M 134-24-5533
Ali 23 M 234-9988775
The term “information” is sometimes used for data with given attributes of in other words
meaningful or processed data.
Data Structure
In computer science, a data structure is a particular way of storing and
organizing data in a computer’s memory so that it can be used
efficiently.
On the other hand, the structure should be simple enough that one can
effectively process the data whenever necessary.
What is this Course About?
element
Example
A linear array STUDENT consisting of the name of six students
STUDENT
1 Dalia Rahaman
2 Sumona
3 Mubtasim Fuad
4
Anamul Haque
5
6 Ibtisam Rahaman
Jarin
MATRICES
1 2 3 4
1 1 2 3 4
Here, MATRICES[3,3]=11
2 5 6 7 8
3 9 10 11 12
4 13 14 15 16
Array Data Structure
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
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.