Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the fastest way to look through an array containing all English words fo

ID: 3724019 • Letter: W

Question

What is the fastest way to look through an array containing all English words for a specific word?
Let’s say I have an array with 100,000 English words (made up number) and I have to find the word “run”. What’s the fastest way to retrieve that given that the array is in alphabetical order? What is the fastest way to look through an array containing all English words for a specific word?
Let’s say I have an array with 100,000 English words (made up number) and I have to find the word “run”. What’s the fastest way to retrieve that given that the array is in alphabetical order?
Let’s say I have an array with 100,000 English words (made up number) and I have to find the word “run”. What’s the fastest way to retrieve that given that the array is in alphabetical order?

Explanation / Answer

Solution:

What is the fastest way to look through an array containing all English words for a specific word?

The fastest way to search for an English word in an array of words is to search it using binary search algorithm, which will give us the result in O(log n) time. Where n is the number of words inside the array.

Let’s say I have an array with 100,000 English words (made up number) and I have to find the word “run”. What’s the fastest way to retrieve that given that the array is in alphabetical order?

Here the array is in alphabetical order, so we will first compare our word which is 'run' with the number placed on 50, 000 place and if our word is smaller than 50000th element then we will go to the left else on the right hand side.

we will again compare (50000+0)/2 the element (in case of left-hand side which means run is smaller than 50000th elements), else we will compare with (50000+100000)/2th element in the right-hand side.

and we can continue this recursively and then run will be found in the array.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote