01 Intro To Course DSA
01 Intro To Course DSA
Introduction to
Data Structures and Algorithms
1
About Me
2
Contact Details/Check Outline
• Email Address
– Sohail.Iqbal[at]seecs.edu.pk
• Counseling hours
– Wednesday (1500 hrs to 1700 hrs)
• Office
– HPC Lab, near SEECS seminar hall.
3
All bits and bytes?
Digital Data Must be..
• Arranged
– Stored in an orderly way in memory / disk
• Accessed
– Find data matching some condition
– Insert new data
– Remove old data
• Processed
– Algorithms: shortest path, minimum cut, FFT, ...
Data Structures Data StructurING
What is a Data Structure?
• Data Structure => Data StructurING
7
Thanks to passionate teacher Dr. Yasir Faheem for sharing this
poster and many other beneficial material on Algorithms (20 books)
Why to perform Data Structuring?
• How does Google quickly find web pages that contain a
search term?
10
What is a Data Structure Anyway?
• It’s an agreement about:
– How to store a collection of objects in memory,
– What operations we can perform on that data,
– The algorithms for those operations, and
– How time and space efficient those algorithms are.
What is a Data
Structure Anyway?
Example. List data structure
• Issues
– Space needed
– Operations efficiency (Time required to complete
operations)
• Retrieval
• Insertion
• Deletion
15
Which data structure to use?
• Data structures let the input and output be
represented in a way that can be handled
efficiently and effectively
array
Linked list
queue
tree stack
16
• Ordering Data Organizing Principles
– Put keys into some order so that we know something
about where each key is relative to the other keys.
– Phone books are easier to search because they are
alphabetized.
• Linking
– Add pointers to each record so that we can find related
records quickly.
– E.g. The index in the back of book provides links from
words to the pages on which they appear.
• Partitioning:
– Divide the records into 2 or more groups, each group
sharing a particular property.
– E.g. Multi-volume encyclopaedias (Aa-Be, W-Z)
Linking
DataType Array[N] Value
Index 0 1 2 3 4 5 .. N-1
Part 1
– Introduction to data structures &
algorithms
– Pointers, structures & arrays
– Lists
• Array lists
• Linked Lists (single, double & circular)
– Stacks (and its applications)
– Queue
– Priority Queue
– Dequeue
Source: /v2-5dd21bea8b50af177e31351ed0https://pic1.zhimg.coma2ea8d_r.jpg?
source=172ae18b
21
Course content
Part 2
– Algorithmic complexity
analysis
– Searching algorithms
– Sorting algorithms
(bubble, insertion,
merge, quick-sort)
– Recursion
22
Source: https://pic1.zhimg.com/v2-5dd21bea8b50af177e31351ed0a2ea8d_r.jpg?source=172ae18b
Course content
Part 3
Source: https://pic1.zhimg.com/v2-5dd21bea8b50af177e31351ed0a2ea8d_r.jpg?source=172ae18b
Trees (binary tree, kd trees)
Graphs
Search algorithms (Depth First Search)
Minimum Spanning Trees & Shortest path algorithm
Hash tables
23
Why so Many Data Structures and
Algorithms?
• Space and time complexity of data structures and algorithms may vary significantly.
• Suppose, we want to find a value in a database with n= 1 million entries.
– Array-list
• Linear search O(n)
• If list sorted - Binary search O(log2n)
• If list unsorted - Binary search O(log2n) not possible!
• Memory over/under allocation
– Linked list
• Linear search O(n)
• Binary search O(log2n) not possible!
• dynamic memory allocation
– Binary search tree (unbalanced)
• Search O(n) – efficient memory utilization
– Balanced BST (AVL)
• Search O(log2n)
– Hash tables – Insertion, searching O(1) Yay!!! Wait. What? How? Excited? Stay
tuned!
Why so Many Data Structures and
Algorithms?
• Space and time complexity of data structures and algorithms may vary significantly.
• Suppose you want to sort n number of elements. Many sorting algorithms available in the literature.
• Bubble sort: N2 in best and worst cases
• Insertion sort
– N in best, and N2 in worst case
• Merge sort
– Worst case: O(nlog2n)
– Space complexity is of order 2n
• Needs temporary array
• Quick sort
– Best case: O(nlog2n), worst case: O(n2)
– Space complexity is of order n
• Conclusion: There is no clear winner!
Summary
• Abstract Data Types are a way to encapsulate and hide the implementation of a data structure,
while presenting a clean interface to other programmers.
28
Assignment Policy
•The course website LMS (Enrollment Code :510372498)
will be the primary source submitting assignments. May also
require uploading a one pdf scan of your handwritten
solutions.
Late Submissions
•Late submission will get a 0% penalty up to one day late.
(don’t avail this grace period)
• –30% penalty for more than 1 day late (No acceptation
after 2 days from deadline)
• Email instructor at least 03 days before the deadline, if
case of any genuine reason. 29
Plagiarism Policy and AI Tools
• Collaboration and group wok is encouraged but each
student is required to submit his/her own contribution(s).
Your writings must be your own thoughts. You must cite
and acknowledge all sources of information in your
assignments.
• Cheating and plagiarism will not be tolerated and will lead
to strict penalties including zero marks in assignments as
well as referral to the Dean for appropriate action(s).
• ChatGPT is allowed for the constructive works. E.g.
ChatGPT can provide concrete examples of algorithms,
helping students to understand and apply concepts.
30
Skills you’ll learn
34
Any Questions/Comments?
Thank You!
35