What is the time complexity of the linear search algorithm in the worst case?
- O(1)
- O(log n)
- O(n)
- O(n^2)
The linear search algorithm has a worst-case time complexity of O(n) because in the worst scenario, it needs to iterate through the entire array to find the target element.
Loading...
Related Quiz
- The use of inline functions can potentially lead to faster execution time but may also increase the ________ of the binary.
- In a graphics program, you need to define colors where each color can be represented as either a name or an RGB triplet. How would you efficiently represent this in C?
- The ________ function is used to write data to a file in C.
- A structure containing an instance of another structure within it is known as a ________ structure.
- In C programming, what is a common use case for having an array of structures?