0%
0 / 15 answered
Informal Run-Time Analysis Practice Test
•15 QuestionsQuestion
1 / 15
Q1
A program searches an unsorted list of $n$ usernames to find a target name.
public static int findUser(String[] users, String target) {
for (int i = 0; i < users.length; i++) {
if (users<u>i</u>.equals(target)) {
return i;
}
}
return -1;
}
How does the run-time of this algorithm change as the input size doubles?
A program searches an unsorted list of $n$ usernames to find a target name.
public static int findUser(String[] users, String target) {
for (int i = 0; i < users.length; i++) {
if (users<u>i</u>.equals(target)) {
return i;
}
}
return -1;
}
How does the run-time of this algorithm change as the input size doubles?