Linear search and binary search
A linear search checks each item in a list one at a time until it finds the target or reaches the end. It works on any list, sorted or not, but in the worst case it must look at every item, so a list of 1,000,000 items can take up to 1,000,000 checks. A binary search works only on a sorted list: it checks the middle item, and if that is not the target, it throws away the half that cannot contain it and repeats on the other half. Because each step cuts the remaining list in half, binary search needs at most about 20 checks for a list of 1,000,000 items and about 10 for 1,000 items. The trade-off is that the list must already be sorted, and sorting takes time too, so binary search pays off most when the same sorted list is searched many times.
This explanation is AI-generated and can occasionally be wrong.
Vibistic AI
🔒 We never store your messages. The free built-in AI runs through Vibistic's own server, on Cloudflare's own AI infrastructure. You can also add your own API key to send messages straight from your browser to your AI provider instead.
Your notes
Test your knowledge
This test is AI-generated and can occasionally be wrong. If something looks off, use Report below.
No API key configured yet. Clicking below will ask whether to add one or take a free version of this test when one is available.
Midterm
This test is AI-generated and can occasionally be wrong. If something looks off, use Report below.
No API key configured yet. Clicking below will ask whether to add one or take a free version of this test when one is available.
This final covers a lot of topics, so it's split into 2 parts. Each part includes a question from every one of its topics.
Final, Part 1 of 2
This test is AI-generated and can occasionally be wrong. If something looks off, use Report below.
No API key configured yet. Clicking below will ask whether to add one or take a free version of this test when one is available.
Final, Part 2 of 2
This test is AI-generated and can occasionally be wrong. If something looks off, use Report below.
No API key configured yet. Clicking below will ask whether to add one or take a free version of this test when one is available.