Junior — Middle
What is the time complexity of searching for an element by key in an unsorted array?
sobes.tech AI
Answer from AI
In an unsorted array, to find an element by key, it is usually necessary to check each element one by one until the desired one is found. Therefore, the time complexity of such a search is O(n), where n is the number of elements in the array. This means that in the worst case, all elements will need to be checked.