Lecture 1 Basic Concepts Related To DSA

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 36

#LifeKoKaroLift

Data Structures and Algorithm


CSE-228

1
Course : Data Structures and
Algorithm
Lecture On : Course Overview,
Basic
EditConcepts
Master text and
stylesNotation

Day – 1
Instructor : Shubham Sharma

2
Today’s Agenda
● Course Overview

● The aim of studying DSA

● How to analyze a Data Structure or Algorithm?

● Ways of measuring running time

● Analysis of Data Structures and Algorithms

● Asymptotic Notations

● Asymptotic Analysis with an example

3
Course Details

• L T P – 2 0 3 [hours per week]

• References

○ DATA STRUCTURES AND ALGORITHMS by ALFRED


V. AHO, JEFFREY D. ULLMAN AND JOHN E.
HOPCROFT, PEARSON, PEARSON
○ DATA STRUCTURES AND ALGORITHMS IN JAVA by
MICHAEL T. GOODRICH AND ROBERTO TAMASSIA,
JOHN WILEY & SONS
Course Assessment Model

• Marks break up

• Attendance 05

• CA ( Mini Project + Best 1 out of 2 CA) 25 (20 + 15 * 2)

• MTE (0% Theory, 100% MCQ) 20

• ETE (50% Theory, 50% MCQ) 50

• Total 100
Course Outcomes

• Describe the process to find


efficiency of algorithms using
asymptotic notation

• illustrate the importance of Queue in


context of problems solving

• differentiate the HashTable and


HashMap in context of writing
efficient program
Course Outcomes

• Identify the appropriateness of


HashSet and tree in problem
solving

• Analyze the effectiveness of Priority


queue and Heap Data Structures

• Use of Graph and various


techniques in real world problem
solving
Program Outcomes achieved from the course

• Conduct investigations of complex problems: Use research-based


knowledge and research methods including design of experiments,
analysis and interpretation of data, and synthesis of the information to
provide valid conclusions.

• Modern tool usage: Create, select, and apply appropriate techniques,


resources, and modern engineering and IT tools including prediction
and modeling to complex engineering activities with an understanding
of the limitations.

• Life-long learning: Recognize the need for, and have the preparation
and ability to engage in independent and life-long learning in the
broadest context of technological change.
Program Educational Objectives

• Those employed in industry will be able to apply fundamentals of


technical knowledge in multidisciplinary areas related to automobile,
thermal, manufacturing and mechatronics by participating as top
professionals in leading Industries.

• Pursue advanced education, research and development in science,


engineering, and technology, as well as other professional endeavors.

• Be receptive to professional and ethical responsibilities for the impact


of engineering solutions on society being as a successful innovator,
consultant and entrepreneur
Program Outcomes achieved from the Course

● Engineering knowledge: Apply the knowledge of mathematics, science,


engineering fundamentals, and an engineering specialization to the solution of
complex engineering problems.

● Design/development of solutions: Design solutions for complex engineering


problems and design system components or processes that meet the
specified needs with appropriate consideration for the public health and safety,
and the cultural, societal, and environmental considerations.
Course Contents
Unit I:

• Introduction :
○ Basic Data Structures
○ Basic Concepts and Notations
○ Complexity analysis: time space and trade off
○ Omega Notation
○ Theta Notation
○ Big O notation
• Stacks :
○ Introduction to Stacks
○ Parenthesis matching problem using Stacks
○ Implementing a stack
○ Industry demonstration: File versioning system
Course Contents

Unit II:

• Queues :
○ Introduction to Queues
○ Ticket booking system using Queues
○ Implement a stack using two queues
○ Implement a stack using one queue
○ Palindromic string problem
○ Duplicate parenthesis problem
○ Reversing a stack problem
○ Kth largest element problem
Course Contents

Unit III:

● HashTables :
○ Design and performance analysis of hash tables
○ Hash functions and hashing
○ Collision in hash tables
○ How to check if a given hash function is good or bad
○ Implementation of a dictionary (phone book) using a hash table
● HashMaps :
○ Introduction to the HashMaps
○ Find Symmetric Pairs problem
○ First Unique Character problem
Course Contents

Unit IV:

• HashSets :
○ Introduction to the HashSets
○ Array of Contiguous Integers problem
○ Pair with a Given Sum problem
○ Itinerary From all Tickets problem
○ Match Locks and Keys problem
• Binary Trees :
○ Title problem: Runway Reservation
○ Linear vs non-Linear data structures
○ Trees & Binary Trees
○ Properties
○ Types & Representation of binary trees
Course Contents

Unit IV:

• Binary Trees (contd.)


○ Tree Traversal: DFS & BFS
○ Mirroring a tree problem
○ Spiral order traversal of a tree
• Binary Search Trees :
○ Introduction to the Binary Search Trees
○ Searching, Insertion & Deletion in a BST
○ Lowest common ancestor problem
○ Balanced BSTs, Solution of the Title Problem
Course Contents

Unit V:

• Priority Queues :
○ Introduction to the Priority queues with example
○ Priority queues ADT
○ Implementation of priority queues using LinkedList and ArrayList
• Heaps :
○ Introduction to the Heaps
○ Basic operations performed on heaps
○ Sorting, Merge k sorted linked list problem
○ Median of stream of integers problem
Course Contents

Unit VI:

• Graphs and Graph Algorithms :


○ Depth-First Search
○ Breadth-First Search
○ Edge list, Adjacency matrix
○ Adjacency list
○ Dijkstra’s algorithm
○ Application of graphs in real life
The aim of studying DSA

• AIM: Design of a “GOOD” data structure and algorithm

• Data structure: Systematic way of organizing and accessing data

• Algorithm: Step-by-step procedure for performing some task in a


FINITE amount of time. (an algorithm must finish)

• So how do we decide goodness of a data structure or an algorithm?


How to analyze a Data Structure or an Algorithm?

• Most important resource for a computer: Time

• So most natural measure of goodness? : Running time


• Of data structure operation (search, access, insert, delete, etc.)
• Of algorithm

• Running time depends on


• Input size
• Kind of input for same size
• Hardware Environment
• Software environment

• We will only focus on Running time as a function of input size n


Ways of measuring running time

• Experimental Studies

• Limitations

• Limited set of inputs (can’t practically test on every input)

• Comparison between algorithms is difficult (without conducting

experiments on similar HW and SW)

• Algorithm must be fully implemented to perform experimental

studies with it
Ways of measuring running time

• Counting Primitive Operations

• Primitive operations = constant running time

• Example: Add, assign, increment, relational operators, etc.

• Number of POs is proportional to Running-time

• Assumption: Running-times of different primitive operations

will be fairly similar


Analysis of Data Structures and Algorithms

• Average case analysis is difficult

• It would be great if we could. . .

• EXPRESS RUNNING-TIME as a function of INPUT-SIZE obtained by

taking AVERAGE OVER ALL POSSIBLE INPUTS of same size

• But it would involve probability theory and it is impossible to

consider all possible inputs for a given input size


• SO WE GENERALLY CHARACTERIZE RUNNING-TIMES using WORST CASES
Analysis of Data Structures and Algorithms

• Growth Rates
• We focus on growth rate of the running time as a function
of input size “n” (at what rate running time increases with
increasing input size)
Ways of measuring running time

• Worst Case Analysis Advantages

• Simpler

• Creates better algorithms


(performance-wise)
Asymptotic Notation
Asymptotic Notation

Curves Asymptotes
Asymptotic Notations

• Big O Notation

Allows us to say that a function is LESS


THAN OR EQUAL TO another function g(n)
Up to a constant factor

“f(n) is order of g(n)”


“f(n) is BIG O of g(n)”

Allows us to ignore constant factors and


lower order term (focus on term that affects
its growth)
Asymptotic Notations

• Big O Notation

Always characterize functions in the simplest terms


Be mindful of LARGE constants
Asymptotic Notations
Asymptotic Notations
Asymptotic Notations

• Big Omega Notation

Allows us to say that a function is GREATER


THAN OR EQUAL TO another function g(n)
Up to a constant factor
Asymptotic Notations

• Big Theta Notation

Allows us to say that a function is GREATER


THAN OR EQUAL TO function g(n)
For a constant factor and is less than or equal
to another function for a different constant
factor
Any Questions?
Feedback Form

Liked what you


learnt?
Tell me in the
comment
section below . . .
Key Takeaways
● Course Overview

● The aim of studying DSA

● How to analyze a Data Structure or Algorithm?

● Ways of measuring running time

● Analysis of Data Structures and Algorithms

● Asymptotic Notations

● Asymptotic Analysis with an example

35
#LifeKoKaroLift

Thank You!

36

You might also like