0
0
Software Engineeringknowledge~5 mins

Use case diagrams in Software Engineering - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Use case diagrams
O(a * u)
Understanding Time Complexity

When working with use case diagrams, it's helpful to understand how the effort to create or analyze them grows as the system gets bigger.

We want to know how the time needed changes when more actors or use cases are added.

Scenario Under Consideration

Analyze the time complexity of the following process for creating a use case diagram.


// Pseudocode for creating a use case diagram
for each actor in systemActors:
    identify use cases for actor
    for each use case:
        draw use case
        connect actor to use case
    end for
end for
    

This code shows how we add actors and their related use cases to the diagram step by step.

Identify Repeating Operations

Look at the loops that repeat actions:

  • Primary operation: Drawing and connecting each use case for every actor.
  • How many times: For each actor, we repeat for all their use cases.
How Execution Grows With Input

As the number of actors and use cases grows, the work grows too.

Input Size (actors x use cases)Approx. Operations
10 actors x 5 use cases50
100 actors x 5 use cases500
100 actors x 50 use cases5,000

Pattern observation: The total steps increase roughly by multiplying the number of actors by the number of use cases.

Final Time Complexity

Time Complexity: O(a * u)

This means the time needed grows in proportion to the number of actors times the number of use cases.

Common Mistake

[X] Wrong: "Adding more actors doesn't affect the time much because use cases stay the same."

[OK] Correct: Each new actor usually has its own use cases or connections, so more actors mean more work overall.

Interview Connect

Understanding how the size of a system affects the effort to model it helps you plan and communicate clearly in real projects.

Self-Check

"What if each actor shared the same set of use cases instead of having unique ones? How would the time complexity change?"