Data Structures and
Algorithms
Lecturer: Kelvin Ouma
Intended Learning Outcomes
By the end of this session, you should be able to:
• Understand the role of DSA in software development
• Classify types of data structures
• Describe basic operations on data structures
• Explain algorithm analysis and Big O notation
• Identify characteristics of a good algorithm
• Understand basic algorithm design techniques
Why Learn Data Structures and Algorithms?
• Essential for writing efficient code
• Helps in solving complex real-world problems
• Critical for technical interviews and coding challenges
• Improves code performance and scalability
• Enables better system design and architecture decisions
What is a Data Structure?
• A data structure is a way of organizing and storing data to perform operations
efficiently.
• Used in almost every software system.
• Examples: arrays, linked lists, trees, stacks, hashmaps, set etc.
Major Classifications
Data Structures are broadly classified into:
• Primitive Data Structures
• Non-Primitive Data Structures
Primitive Data Structures
Directly operated upon by machine instructions.
• Examples:
▪ Integer
▪ Float
▪ Character
▪ Boolean
• Typically provided by programming languages.
Non-Primitive Data Structures
These are more complex and are built using primitive data types.
Two main types:
• Linear Data Structures
• Non-Linear Data Structures
Linear Data Structures
• Data elements are arranged in a linear sequence.
• Examples:
▪ Arrays
▪ Linked Lists
▪ Stacks
▪ Queues
• Easy to implement and understand.
Non-Linear Data Structures
• Elements are not arranged in a sequence.
• Used to represent hierarchical relationships.
• Examples:
▪ Trees
▪ Graphs
Static vs Dynamic Data Structures
• Static Data Structures:
o Fixed size.
o Example: Arrays.
• Dynamic Data Structures:
o Can grow or shrink in size.
o Example: Linked Lists.
Homogeneous vs Non-Homogeneous Data
Structures
Homogeneous Data Structures
• Store same type of data elements.
• Memory is allocated uniformly.
• Examples:
• Arrays (all elements of type int, float, etc.)
• Stacks and Queues (if implemented using arrays or singly typed lists)
Non-Homogeneous Data Structures
• Can store different types of data elements.
• Flexible in design and real-world modeling.
• Examples:
o Structures (in C/C++)
o Objects/Classes (in OOP)
o JSON (key-value data with varying types)
Importance of DSA in Software Development
• Determines how data is stored and manipulated
• Affects speed, memory usage, and user experience
• Used in backend, frontend, AI, ML, databases, etc.
• Examples:
o Searching in large datasets
o Routing in GPS apps
o Scheduling in operating systems
Characteristics of an Algorithm
• Input: Zero or more inputs
• Output: At least one output
• Finiteness: Must terminate
• Definiteness: Each step is clear
• Effectiveness: Can be done by machine
Operations on Data Structures
• Insertion: Add elements
• Deletion: Remove elements
• Traversal: Access every element
• Searching: Find specific element
• Sorting: Order elements
• Updating: Modify elements
Analyzing Algorithms
• Time Complexity: How long it takes
• Space Complexity: Memory required
• Best, Worst, Average Case