Data Structures & Algorithms 01
Data Structures & Algorithms 01
Lecture # 01
Mr. Muhammad Arshad
Introduction
• Data: data are simply values or set of values. A data items refers to a
single unit of values. Data items that are divided into sub items are
called group items. For example Employee name may be divided into
three sub items _ first name, middle name and last name.
• Entity: An entity is something that has certain attributes or properties
which may be assigned values. The values themselves may be either
numeric or non numeric.
Example:
Attribute Name Age Gender Number
Values John 34 Male 134-24553-3
Data Structure
• Data structures help us to organize the data in the computer, resulting
in more efficient programs. An efficient program executes faster and
helps minimize the usage of resources like memory, disk. Computers
are getting more powerful with the passage of time with the increase
in CPU speed in GHz, availability of faster network and the
maximization of disk space. Therefore people have started solving
more and more complex problems. As computer applications are
becoming complex, so there is need for more resources
Need for Data Structures
• Data structures organize data more efficient programs.
• The choice of data structure and algorithm can make the difference
between a program running in a few seconds or many days.
Efficiency
A solution is said to be efficient if it solves the problem within its
resource constraints.
Space
Time
Real life:
a. shopping list,
b. groceries list,
c. list of people to invite to dinner
d. List of presents to get
Lists
A list is collection of items that are all of the same type (grocery
items, integers, names)
The items, or elements of the list, are stored in some particular order
In this list, a3, is the first element, a1 is the second element, and so on
1. Use the actual index of element: insert after element 3, get element number
6. This approach is taken by arrays
2. Use a “current” marker or pointer to refer to a particular position in the list.
List Operations
If we use the “current” marker, the following four methods would be
useful: