Search intent types (informational, navigational, transactional) in SEO Fundamentals - Time & Space Complexity
When analyzing search intent types, we want to understand how the effort to identify user goals grows as the number of queries increases.
How does the process of categorizing search intents scale with more search data?
Analyze the time complexity of the following pseudo-code for classifying search intents.
for each query in search_queries:
if query contains question words:
classify as informational
else if query matches known site names:
classify as navigational
else:
classify as transactional
store classification
This code checks each search query to decide if it is informational, navigational, or transactional, then saves the result.
Look for repeated steps that take most time.
- Primary operation: Looping through each search query once.
- How many times: Exactly once per query, so as many times as there are queries.
As the number of queries grows, the work grows in a similar way.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 checks |
| 100 | 100 checks |
| 1000 | 1000 checks |
Pattern observation: Doubling the queries doubles the work needed.
Time Complexity: O(n)
This means the time to classify search intents grows directly with the number of queries.
[X] Wrong: "Classifying search intents takes the same time no matter how many queries there are."
[OK] Correct: Each query needs to be checked, so more queries mean more work.
Understanding how work grows with input size helps you explain your approach clearly and shows you think about efficiency in real tasks.
"What if we added a nested loop to compare each query with every other query? How would the time complexity change?"