0% found this document useful (0 votes)
68 views

01 Intro To Course DSA

This document provides an overview and syllabus for a course on data structures and algorithms. It introduces key concepts like data structuring, different data structures like arrays and linked lists, and algorithms. It outlines the course content which will cover common data structures, searching and sorting algorithms, and algorithm analysis. Assessment will include assignments, quizzes, a midterm, and a final exam. The goal is to teach students how to organize and process data efficiently using different data structures and algorithms.

Uploaded by

Haseeb Muhammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

01 Intro To Course DSA

This document provides an overview and syllabus for a course on data structures and algorithms. It introduces key concepts like data structuring, different data structures like arrays and linked lists, and algorithms. It outlines the course content which will cover common data structures, searching and sorting algorithms, and algorithm analysis. Assessment will include assignments, quizzes, a midterm, and a final exam. The goal is to teach students how to organize and process data efficiently using different data structures and algorithms.

Uploaded by

Haseeb Muhammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

CS250: Data Structures and Algorithms

Introduction to
Data Structures and Algorithms

Instructor: Dr. Sohail Iqbal

1
About Me

• Sohail Iqbal, PhD.


• Associate Professor
• Lab Director - High Performance Computing
• Joined NUST in 2011 and taught BSCS-1
• Love Algorithms!
• Current Research in LLMs (ChatGPT equivalents)
• YouTube: https://www.youtube.com/@sohailmath

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

– How do we organize information so that we can


find, update, add, and delete portions of it
efficiently?

– Data Structure is a systematic way to organize data


in order to use it efficiently

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?

• How can dictionary quickly find meaning of the


searched words?

• In the game Counter Strike, how can the computer


determine which parts of the scene are visible?

• How many cities with more than 250,000 people lie


within 500 km of Islamabad?
9
Why to perform Data Structuring?

• Can we connect all of our telephone customers with


less than 1,000 kms of cable?

To answer questions like these, it is not enough to have


the necessary information.

We must organize that information in a way that


allows us to find the answers in time to satisfy our needs

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

• A collection of homogeneous elements


with linear relationship b/w them. E.g.
mobile organizer.
• Operations: Can access, change, insert
or delete elements
• Algorithms: linear vs binary search.
• Time Complexity: linear search O(n),
binary search in array-list O(log2n) .
More operations later.
What about algorithms (Review)

• Algorithms: how to access data for a result?


– Scan data sequentially
– Scan data according to the sequence of a
structure
– Scan data with “formula”

• Algorithms: how to provide a smart solution


Why is Data StructurING necessay?
Three common problems:
• Data Search
– E.g., an inventory of 1 million(106) items of a store
• Processor Speed
– Processor speed although being very high, falls
limited if the data grows to billion records
• Multiple Requests
– As thousands of users can search data
simultaneously on a web server, even the fast
server fails while searching the data
14
Example
• Data structure for storing data of students:-
– Arrays
– Linked Lists

• 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

• Records located any where in memory


• Pointers give “next” element
• Don’t have to know size of data at start
• Pointers let us express relationships between pieces of information.
Partitioning
• Ordering implicitly gives a partitioning based on the “<“ relation.
• Partitioning usually combined with linking to point to e.g. two halves.
• Prototypical example is the Binary Search Tree:
Course content

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

• Much of programming (and thinking about programming) involves deciding


– how to arrange information in memory. [Aka data structures.]

• Choice of data structures can make a big speed difference.


– Sequential search vs. Binary Search means O(n) vs. O(log n).
– [log (1 billion) < 40].

• Abstract Data Types are a way to encapsulate and hide the implementation of a data structure,
while presenting a clean interface to other programmers.

• Data structuring principles:


– Ordering
– Linking
– (Balanced) partitioning
Marks Distribution (Tentative)

• 05% Assignments (03 at-least)

• 15% Quizzes (05 at-least, Surprise!)

• 30% Mid-Term exam

• 50% Final Exam

• 100% Total. (Grade is a byproduct!)


27
Quiz Policy
• The quizzes can be unannounced/announced
• The question framed is to test the concepts involved
in last few lectures.
• Missed quizzes will not be retaken/compensated.
• Quiz marks is a way to honor punctual students.
• Don’t email for “Don’t take quiz”. Won’t be replied
• Bonus: Any student with attendance at least 80%,
will get bonus marks by replacement of the minimum
quiz score by the maximum.

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

• Become a better programmer


• Sharpen your mathematical and analytical skills
• Start “thinking algorithmically”
• Ace your technical interviews
• Appreciate the beauty of Data Structures and
Algorithms!
31
Lecture slides/material on LMS
• Text book, course outline, all lecture slides
available at LMS.

• I usually update the material for better


examples etc.

• Please use the latest version of slides for your


Mid/ESE.
32
Recommended Books
Text book:
– Object Oriented Data Structures Using C++ by Nell
Dale, Jones and Bartlett Publishers.
Reference books:
– Adam Drozdek, Data Structures and Algorithms in
C++ (Fourth edition)

– T. H. Cormen, Charles E. Leiserson, R. L. Rivest,


Clifford S. Introduction to Algorithms, (Third
Edition)
Class ethics
• Attendance (75% mandatory)
• Be disciplined & give respect to all
• Feel free to ask questions anytime!
• Expect quizzes anytime
• Assignments & lab exercises

34
Any Questions/Comments?

Thank You!

35

You might also like