CS2001 – DATA STRUCTURES
Lecture # 01
August 21, 2023 Dr. Rabia Maqsood
Fall 2023 [email protected]
FAST – NUCES, CFD Campus
CS 2001 - FALL 2023 1
TODAY’S TOPICS
Background of the class
Why study Data Structures?
Introduction to Data Structures
Course, Conduct & Myself
CS 2001 - FALL 2023 2
TO DO…
What have you learnt so far in PF & OOP courses?
How were you storing & retrieving data?
Data was minimal so far…
What if we want to design a dictionary, to-do list, city’s map?
To store and manipulate with larger data, we need better mechanisms ….
We need DATA STRUCTURES!!!
CS 2001 - FALL 2023 3
WHAT THIS COURSE IS ABOUT ?
Studying, analyzing, designing and implementing conceptual and concrete ways to
organize data for efficient storage and efficient manipulation
This course is not about C++
But you will use C++ as a language for implementation
CS 2001 - FALL 2023 4
EFFICIENT STORAGE & MANIPULATION
Lists, Stacks, Queues Insert
Binary Search Trees
Delete
AVL Trees
Hash Tables Find
Graphs Merge
Heaps
Shortest Paths
Disjoint Sets
Union
Data Structures Algorithms
(efficient storage) (efficient manipulation)
CS 2001 - FALL 2023 5
WHAT IS A DATA STRUCTURE?
In a general sense, any representation that is used for storing information is a data
structure
More typically, a data structure provides a way of organization for a collection of
data items
Algorithm + Data Structure = Program
CS 2001 - FALL 2023 6
BASIC DATA STRUCTURES Choose the best data structure
based on its application
Linked List
Queue
Tree
Stack CS 2001 - FALL 2023 7
EFFICIENCY
A solution is said to be efficient if it solves the problem within its resource constraints.
Space (memory)
Time
The cost of a solution is the amount of resources that the solution consumes
CS 2001 - FALL 2023 8
EXAMPLE
A collection of 3,000 texts with avg. of 20 lines each, with avg. 10 words / line
® 600,000 words
We want to find all occurrences of the word “happy”
Suppose it takes 1 sec. to check a word for correct matching
What to do?
CS 2001 - FALL 2023 9
EXAMPLE (CONT’D)
Choices we have:
Sol. 1 Sequential matching: 1 sec. x 600,000 words = 166 hours
Sol. 2 Binary searching:
- order the words
- search only half at a time
Ex. Search 25 in 5 8 12 15 15 17 23 25 27
25 ? 15 15 17 23 25 27
25 ? 23 23 25 27
25 ? 25
How many steps?
log 2 600000 = 19 sec. vs .166 hours!
CS 2001 - FALL 2023 10
NEED FOR DATA STRUCTURES
Programs’ designs depends crucially on how data is structured for use by the
program.
It can affect in several ways:
Implementation of some operations may become easier or harder.
Speed of program may dramatically decrease or increase.
Usage of memory may decrease or increase.
CS 2001 - FALL 2023 11
ORGANIZING DATA
Any organization for a collection of records that can be searched, processed in any
order, or modified.
The choice of data structure and algorithm can make the difference between a
program running in a few seconds or many days.
CS 2001 - FALL 2023 12
COURSE, CONDUCT & MYSELF
CS 2001 - FALL 2023 13
COURSE OUTLINE 3+1 credit hours Absolute Grading
1.5 weeks • Introduction to Data Structures & ADTs (revision oop/pointers), time complexity
2 weeks • List ADT, singly & doubly linked list
1 week • Stack ADT
1.5 week • Queue ADT
3 weeks • Recursion + Tree ADT, BSTs, some variants of height balanced trees (AVL/B-trees)
2 weeks • Graph ADT
1 week • Hashing
1 week • Heap
2 weeks • Algorithms: searching, sorting
CS 2001 - FALL 2023 14
COURSE BOOKS
CS 2001 - FALL 2023 15
COURSE OBJECTIVES
To familiarize students with abstract data types, elementary data structures, and algorithms for
operations associated with them.
To develop the skills to analyze time and space requirements for a data structure and associated
algorithms.
To prepare students for applying sophisticated data structures and techniques in dealing with complex
problems and data structures.
To provide toolkit to students so that they can design new data structures in the future.
CS 2001 - FALL 2023 16
TENTATIVE MARKS DISTRIBUTION
To be announced…
Join the GoogleClassroom: nuayha6
(for course material, assignments submission, and all
announcements)
CS 2001 - FALL 2023 17
HONOR CODE
Dishonesty will NOT be tolerated.
All parties involved in any kind of cheating will be punished equally.
It will result in ZERO marks in the corresponding work at least.
CS 2001 - FALL 2023 18
GENERAL GUIDELINES
Be regular & punctual in the class.
Maintain class discipline.
Usage of mobile phones and/or laptops is prohibited.
Check Emails/GoogleClassroom for regular updates.
Confirm your scores as soon as they are updated, no changes will be made later.
Start working on projects/assignments right from the first day.
Read book(s).
Come prepared in the class.
Class participation is encouraged.
Remain attentive during the class. Ask questions.
Raise your hand before you speak.
CS 2001 - FALL 2023 19
HOW TO REACH ME?
Office: Room # G-13, Computer Science Dept.,
Faculty Offices – Ground floor
Office Visiting Hours: to be provided soon
Better to fix an appointment otherwise
Write a “good” email to
Email:
[email protected] get timely response
CS 2001 - FALL 2023 21