173k views
1 vote
In the first part of the assignment, you need to write a program that recursively searches a directory tree. Which programming concept is most suitable for implementing recursive directory search?

a) Iteration
b) Looping
c) Recursion
d) Conditional Statements

Question 588 - Part 2: Binary Search of Strings
The second part of the assignment requires implementing a binary search on a list of strings. What is the time complexity of a binary search algorithm?

a) O(1)
b) O(log n)
c) O(n)
d) O(n^2)

1 Answer

2 votes

Final answer:

The programming concept most suitable for recursive directory search is Recursion, and the time complexity of binary search is O(log n).

Step-by-step explanation:

The concept most suitable for implementing a recursive directory search is c) Recursion. Recursive functions are designed to call themselves with a modified parameter until a base condition is met, making them ideal for navigating through nested structures like directory trees.

For the second part of the assignment, the time complexity of a binary search algorithm is b) O(log n). Binary search is an efficient algorithm that repeatedly divides the sorted list in half to find the target value, leading to a logarithmic time complexity.

User Alexandre Fenyo
by
8.4k points