Software Engineering
SDLC, Data Structures, Algorithms & Design Principles
1. Software Development Life Cycle (SDLC)
SDLC Phases
- 1
Requirements Analysis
Gather and document user needs, create SRS (Software Requirements Specification)
- 2
Design
High-level design (HLD) and low-level design (LLD), create architecture
- 3
Implementation (Coding)
Write code based on design specifications
- 4
Testing
Unit, integration, system, and acceptance testing
- 5
Deployment
Release software to production environment
- 6
Maintenance
Bug fixes, updates, enhancements after deployment
SDLC Models
Waterfall Model
- • Linear, sequential phases
- • Each phase must complete before next
- • No going back to previous phases
- + Simple, well-documented
- - Inflexible, late testing
- Best for: Well-defined, stable requirements
V-Model
- • Extension of Waterfall
- • Each dev phase has corresponding test phase
- • Testing planned in parallel with development
- + High discipline, early test planning
- - Still inflexible
Iterative/Incremental
- • Software built in increments
- • Each iteration adds functionality
- • Early partial implementation
- + Early feedback, risk reduction
- - Needs good planning
Spiral Model
- • Risk-driven approach
- • Four quadrants: Planning, Risk Analysis, Engineering, Evaluation
- • Each loop is a phase
- + Risk management, iterative
- - Complex, expensive
Agile
- • Iterative, incremental delivery
- • Short sprints (2-4 weeks)
- • Customer collaboration
- • Adaptive to change
Scrum Roles:
- • Product Owner: Requirements, prioritization
- • Scrum Master: Facilitator, removes blockers
- • Development Team: Self-organizing, cross-functional
2. Data Structures
Linear Data Structures
Array
- • Fixed size, contiguous memory
- • O(1) access by index
- • O(n) insertion/deletion (shifting)
- • Cache-friendly
Linked List
- • Dynamic size, non-contiguous
- • O(n) access (traversal needed)
- • O(1) insertion/deletion at known position
- • Types: Singly, Doubly, Circular
Stack (LIFO)
- • Last In, First Out
- • Operations: push(), pop(), peek()
- • O(1) for all operations
- • Uses: Undo, function calls, parsing
Queue (FIFO)
- • First In, First Out
- • Operations: enqueue(), dequeue()
- • O(1) for all operations
- • Uses: BFS, scheduling, buffers
Non-Linear Data Structures
Binary Tree
- • Each node has max 2 children
- • Terms: Root, leaf, height, depth
- • Traversals: Inorder, Preorder, Postorder, Level-order
Binary Search Tree (BST)
- • Left child < parent < right child
- • O(log n) average search/insert/delete
- • O(n) worst case (skewed tree)
- • Inorder gives sorted output
Heap
- • Complete binary tree
- • Max-heap: Parent ≥ children
- • Min-heap: Parent ≤ children
- • O(log n) insert, O(1) find-min/max
- • Uses: Priority queue, heap sort
Graph
- • Vertices (nodes) + Edges (connections)
- • Types: Directed/Undirected, Weighted/Unweighted
- • Representations: Adjacency Matrix, Adjacency List
- • Traversals: BFS, DFS
Hash Table
- • Key-value pairs
- • Hash function maps key to index
- • O(1) average access/insert/delete
- • O(n) worst case (all collisions)
Collision Resolution:
- • Chaining: Linked list at each bucket
- • Open Addressing: Linear probing, quadratic probing, double hashing
3. Algorithm Complexity (Big-O)
Time Complexity
| Notation | Name | Example | n=1000 |
|---|---|---|---|
| O(1) | Constant | Array access, hash lookup | 1 |
| O(log n) | Logarithmic | Binary search | ~10 |
| O(n) | Linear | Linear search, single loop | 1,000 |
| O(n log n) | Linearithmic | Merge sort, Quick sort | ~10,000 |
| O(n²) | Quadratic | Bubble sort, nested loops | 1,000,000 |
| O(n³) | Cubic | Matrix multiplication | 1,000,000,000 |
| O(2ⁿ) | Exponential | Recursive Fibonacci | Huge! |
Space Complexity
Measures memory usage as input grows.
- O(1): Fixed extra space (in-place algorithms)
- O(n): Linear extra space (copying array)
- O(log n): Recursive call stack depth
Sorting Algorithm Comparison
| Algorithm | Best | Average | Worst | Space | Stable |
|---|---|---|---|---|---|
| Bubble Sort | O(n) | O(n²) | O(n²) | O(1) | Yes |
| Selection Sort | O(n²) | O(n²) | O(n²) | O(1) | No |
| Insertion Sort | O(n) | O(n²) | O(n²) | O(1) | Yes |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |
| Quick Sort | O(n log n) | O(n log n) | O(n²) | O(log n) | No |
| Heap Sort | O(n log n) | O(n log n) | O(n log n) | O(1) | No |
4. Common Algorithms
Searching
Linear Search
- • Check each element sequentially
- • Works on unsorted data
- • Time: O(n)
- • Space: O(1)
Binary Search
- • Requires sorted data
- • Divide and conquer
- • Compare middle, eliminate half
- • Time: O(log n)
- • Space: O(1) iterative, O(log n) recursive
Graph Traversals
BFS (Breadth-First Search)
- • Uses Queue
- • Level-by-level traversal
- • Finds shortest path (unweighted)
- • Time: O(V + E)
DFS (Depth-First Search)
- • Uses Stack (or recursion)
- • Go deep before backtracking
- • Good for: Cycle detection, topological sort
- • Time: O(V + E)
Tree Traversals
Inorder
Left → Root → Right
BST: Sorted order
Preorder
Root → Left → Right
Tree copy
Postorder
Left → Right → Root
Tree deletion
Level-order
BFS approach
Uses queue
5. Object-Oriented Programming (OOP)
Four Pillars of OOP
1. Encapsulation
Bundle data and methods that operate on data within a single unit (class).
- • Data hiding using access modifiers
- • Getters/setters for controlled access
- • Protects data integrity
2. Abstraction
Hide complex implementation, show only essential features.
- • Abstract classes (partial implementation)
- • Interfaces (contract, no implementation)
- • Focus on "what" not "how"
3. Inheritance
Create new classes based on existing classes (parent-child).
- • Code reuse
- • Types: Single, Multiple, Multilevel, Hierarchical
- • "is-a" relationship
4. Polymorphism
Same interface, different implementations.
- • Compile-time: Method overloading
- • Runtime: Method overriding
- • "One interface, many forms"
SOLID Principles
S - Single Responsibility
A class should have only one reason to change
O - Open/Closed
Open for extension, closed for modification
L - Liskov Substitution
Subtypes must be substitutable for their base types
I - Interface Segregation
Many specific interfaces better than one general interface
D - Dependency Inversion
Depend on abstractions, not concrete implementations
6. Design Patterns
Creational Patterns
Singleton
Only one instance of a class exists
Factory
Create objects without specifying exact class
Abstract Factory
Create families of related objects
Builder
Construct complex objects step by step
Structural Patterns
Adapter
Convert interface of one class to another
Decorator
Add behavior to objects dynamically
Facade
Simple interface to complex subsystem
Proxy
Placeholder for another object
Behavioral Patterns
Observer
Notify dependents of state changes
Strategy
Define family of interchangeable algorithms
Command
Encapsulate request as an object
Iterator
Sequentially access collection elements
7. Software Testing
Testing Levels
Unit Testing
Test individual components/functions in isolation
Integration Testing
Test interactions between integrated modules
System Testing
Test complete system as a whole
Acceptance Testing
Verify system meets business requirements (UAT)
Testing Types
Black Box
- • Test without knowing internal code
- • Focus on inputs and outputs
- • Functional testing
White Box
- • Test with knowledge of internal code
- • Code coverage testing
- • Statement, branch, path coverage
Testing Techniques
- Boundary Value Analysis: Test at edges of valid ranges
- Equivalence Partitioning: Divide inputs into equivalent groups
- Regression Testing: Ensure changes don't break existing features
- Smoke Testing: Quick tests to verify basic functionality
8. Key Takeaways for CpE Students
Essential Concepts
Big-O Quick Reference
- • O(1): Hash lookup, array access
- • O(log n): Binary search
- • O(n): Linear search
- • O(n log n): Merge/Quick sort
- • O(n²): Bubble/Selection sort
Data Structure Selection
- • Fast lookup: Hash table
- • Sorted data: BST, Heap
- • LIFO: Stack
- • FIFO: Queue
- • Dynamic size: Linked list
OOP Pillars
- • Encapsulation: Data hiding
- • Abstraction: Interface vs implementation
- • Inheritance: Code reuse
- • Polymorphism: Many forms
SDLC Models
- • Waterfall: Sequential, rigid
- • Agile: Iterative, flexible
- • Spiral: Risk-driven
- • V-Model: Test-focused
Algorithm Strategy Selection
Divide & Conquer: Merge sort, Binary search
Dynamic Programming: Fibonacci, Knapsack
Greedy: Huffman, Dijkstra