2. Course Objective
To introduce the concept of data structures including arrays, linked lists,
stacks, queues, binary trees, heaps, binary search trees, and graphs etc.,
and apply these data structures in problem solving.
To introduce applications of various data structures and its use in a manner
that adds to the efficiency of an algorithm in writing effective programs.
3. Course Outcome
After completion of this course, you will be able to
1. Learn how the choice of data structures and algorithm design methods
impact the performance of programs.
2. Analyze the importance and use of Abstract Data Types (ADTs)
3. Design and implement elementary Data Structures such as arrays, trees,
Stacks, Queues, and Hash Tables.
4. Identify algorithms as a pseudo-code to solve some common problems.
5. Explain best, average, and worst-cases of an algorithm using Big-O notation.
6. Data
Data is plural of datum- a piece of information
Data are values or a set of values
Data item refers to single unit of values
Data item
Group item :
Data item that can be subdivided into sub item.
Ex Name : First Name, Middle initial and Last Name
Elementary item:
Data item that can not be sub divided into sub item
Ex : PAN card number / Bank Pass Book Number is treated as single item
7. Elementary Data Organization
Collection of data are frequently organized into a hierarchy of fields,
records and files
Entity :
Something that has certain attributes or properties which may be assigned values
Values may be numeric or non-numeric
Ex: The employee of an organization
Attributes Name Age Sex Employee Code
Values John 33 M 13472
8. Elementary Data Organization
Entity with similar attributes ( e.g all employees of an organization) form an entity
set
Each attribute of an entity set has a range of values [ the set of possible values
that could be assigned to the particular attribute]
Information: Data with given attribute or processed data
Field is a single elementary unit of information representing an attribute of an
entity
Record is the collection of field values of a given entity
Fixed Length
Variable Length
File is the collection of records of the entities in a given entity set
10. Issues in Data Structures
Study of Data Structure includes the following three steps
Logical or Mathematical description of the structure of data
Implementation of the structure on a computer
Quantitative analysis of the structure, which includes determining the amount of
memory needed to store the structure and the time required to process the
structure
Second and third step depends on whether data is stored in main memory
or secondary storage
In this course, we are concerned only with data stored in main memory
11. Data Structure
Data Structure
The logical or mathematical model of a particular organization of data
Choice of a model depends on two factor
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
A data structure is a way to logically organize data that specifies:
A set of data elements i.e., a data object and
A set of operations which may legally be applied to elements of this data object.
12. Operations
Operations:
Data appearing in DS are processed by means of certain operation
A particular DS, one chooses for a given situation depends largely on the frequency
with which specific operations are performed
Main operations
Traversal
Search
Insertion
Deletion
Sort
Issues
Space needed
Operations efficiency (Time required to complete
operations)
15. Algorithms
A list of well defined instructions for solving a particular
problem
High level and language independent instructions
Each instruction must be clear
Finite number of instructions
There may be many algorithms for solving a problem
Good Algorithm: Efficient Algorithm
Time
Space
16. Time-space trade-off
Each algorithm involve a particular data structure
Choice of data structure effect the efficiency of
algorithm
Time-space trade-off
Increasing the amount of space may reduce time
need and vice versa
17. Example: Search Algorithms
Suppose we have a file containing information about
employees
Name, Age, Sex, Telephone Number, Address
We are given name of an employee and want to search
for his/her Telephone number
Linear Search
Traverse the file linearly starting from the first record
Number of comparisons is equal to (n+1)/2
What if file is very large
18. Binary Search
Binary search can be used if names are sorted
alphabetically
General Idea of binary search
Compare given name with the name in the middle of list
Tells which half of the list contains given name
Repeat this process until given name is found
Number of comparisons is log2
n
20. Number of comparisons in Binary
Search
For array of 15 elements, Number of comparisons is
21. Binary Search
Very efficient than linear search
Drawbacks
Sorted list
Direct access to middle element
insertion and deletion in sorted array is difficult
25. Example 2: time space trade-off
Roll No Name
55 Clark
712 Hill
3 Drew
124 White
943 Brown
345 Adams
231 Bill
Roll No can be used as address
No movement od data in insertion and deletion
Instant access to any record
Mostly empty locations- memory is allocated for non-existing records
Efficient Method: Hashing
A hash function H transform a key value K into address L