User feedback collection in No-Code - Time & Space Complexity
When collecting user feedback in a database, it's important to understand how the time to save or retrieve feedback grows as more users submit their opinions.
We want to know how the process scales when more feedback entries are added.
Analyze the time complexity of the following process to save user feedback.
// Pseudocode for saving user feedback
function saveFeedback(feedbackList, newFeedback) {
feedbackList.append(newFeedback);
return feedbackList;
}
This code adds a new feedback entry to the existing list of feedbacks.
Look for any repeated actions that happen as more feedback is collected.
- Primary operation: Adding one new feedback entry to the list.
- How many times: Once per new feedback submission.
Adding a new feedback entry takes about the same time no matter how many feedbacks are already stored.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 1 append operation |
| 100 | 1 append operation |
| 1000 | 1 append operation |
Pattern observation: The time to add feedback stays about the same regardless of how many feedbacks exist.
Time Complexity: O(1)
This means adding a new feedback takes a constant amount of time, no matter how many feedback entries are already stored.
[X] Wrong: "Adding feedback takes longer as the list grows because it has to check all previous feedbacks."
[OK] Correct: Adding to the end of a list usually just places the new item without checking others, so time stays constant.
Understanding how simple operations like adding feedback scale helps you explain database efficiency clearly and confidently in real-world situations.
"What if we had to search through all feedbacks to check for duplicates before adding? How would the time complexity change?"