Intro To Data Structures and Algorithms
Intro To Data Structures and Algorithms
Structures and
Algorithms
D. Mpini
Learning Outcomes
• Why Study Data Structures and Algorithms? • Algorithm Efficiency
• The Role of Data Structures and Algorithms in ○ Space Complexity
Computing
○ Time Complexity
• Importance Across Disciplines
• Data Taxonomy Overview
• Data Type vs. Data Structure
• Introduction to Algorithms
• Algorithm Design Example
• Categories of Algorithms
• Algorithm Characteristics
Why Study Data Structures and Algorithms?
Enhance code Improve memory Enhance job prospects by Develop critical thinking
optimization for better utilization for efficient mastering skills for complex
performance operations problem-solving problem-solving
techniques
https://www.springboard.com/blog/software-engineeri
ng/data-structures-and-algorithms-interview-questions
/
Importance Across Disciplines
Way of Organizing
Examples Which is best? Importance of Data
Data
Structures
Data structures organize Linked lists, queues, heaps, The choice of data Data structures enhance
and store data effectively and graphs are common structure depends on the data management,
in memory locations for data structures each with specific task at hand, retrieval, and manipulation,
easy access and unique strengths and ensuring optimal leading to improved
manipulation. implementation strategies. performance and efficiency program functionality and
in data handling. resource utilization.
Data Taxonomy Overview
Basic classification of data used in code Collection of different forms of data with specific operations
Informs compiler about data type and memory space Organizes items in memory and provides logical access
required
Includes linked lists, queues, heaps, stacks, graphs
Examples include int, string, etc.
Algorithms
Algorithms are finite sequences of Algorithms are not programs; they are Algorithms can be represented in
steps to achieve a specific computing abstract solutions to problems that can
task efficiently. 1. pseudocode for clarity and in
be expressed in pseudocode and
2. flowcharts for visual
flowcharts.
understanding.
Algorithm Design Example
Design an algorithm that takes 2 arrays and return true if the arrays have no common elements in them given that initially each array did not have a
recurring element. Express your algorithm in the form of
a. Pseudocode
b. Flowchart
Categories of Algorithms
1 2 3
Searching algorithms are used to find Sorting algorithms arrange data structures Greedy algorithms aim to find the locally
specific items within a collection of based on a comparison operator. optimal solution in the hopes of achieving
items. the global optimal solution.
4 5 6
Recursive algorithms solve problems by Backtracking algorithms incrementally Dynamic programming algorithms divide
calling themselves with smaller values. find solutions to a problem. problems into subproblems and store
results for future use.
Categories of Algorithms
7 8 8
● This common algorithm is Dynamic programming algorithms. This Hashing algorithms. This algorithm
algorithm solves problems by dividing takes data and converts it into a
divided into two parts. One
them into subproblems. The results uniform message with a hashing.
part divides a problem into are then stored to be applied to future
smaller subproblems. The corresponding problems.
Algorithms must have clear steps and inputs to avoid ambiguity in their execution and
Unambiguous results.
Algorithms must have well-defined inputs and produce specific outputs to achieve their
Input and Output intended purpose.
Algorithms must terminate after a finite number of steps to ensure completion within a
Finiteness reasonable time frame.
• Way to represent the amount of time required by the program • Amount of memory space required by the algorithm during its
to run until its completion execution
• Depends on the size of the input data and the steps involved • Includes instruction space, data space, and environment space
in the algorithm
• Critical for understanding the memory usage of algorithms
• Used to analyze the efficiency of algorithms
Time Complexity
Importance of Time Complexity in Algorithms
● Optimizing time complexity leads to faster and more scalable Plus tip:
algorithms.
Space Complexity
Instruction space is needed to Data space stores constants and Environment space holds
store the executable program variables in the program information required to resume
code suspended functions
Big O Notation
• Tool for describing the time and space complexity of algorithms.
Type Notation Example Algorithms
Logarithmic O(log n) Binary Search
Linear O(n) Linear Search
Superlinear O(n log n) Heap Sort, Merge Sort
Polynomial O(n^c) Strassen’s Matrix Multiplication,
Bubble Sort, Selection Sort, Insertion
Sort, Bucket Sort
Exponential O(c^n) Tower of Hanoi
Factorial O(n!) Determinant Expansion by Minors,
Brute force Search algorithm for
Traveling Salesman Problem