0
0
DSA Javascriptprogramming~5 mins

Why Binary Search and What Sorted Order Gives You in DSA Javascript - Quick Recap

Choose your learning style9 modes available
Recall & Review
beginner
What is the main advantage of using binary search over linear search?
Binary search is much faster because it cuts the search space in half each time, making it efficient for large sorted lists.
Click to reveal answer
beginner
Why must the list be sorted for binary search to work?
Because binary search compares the target with the middle element and decides which half to search next, the list must be sorted to know which half contains the target.
Click to reveal answer
beginner
What does 'sorted order' mean in the context of binary search?
Sorted order means the elements are arranged from smallest to largest (or vice versa), so you can predict where to find elements based on comparisons.
Click to reveal answer
intermediate
How does binary search reduce the number of comparisons compared to linear search?
Binary search divides the list in half each time, so it only needs about log₂(n) comparisons, while linear search may need up to n comparisons.
Click to reveal answer
beginner
What happens if you try to use binary search on an unsorted list?
Binary search will not work correctly because the assumption about sorted order is broken, leading to wrong decisions about which half to search.
Click to reveal answer
Why is a sorted list necessary for binary search?
ATo avoid duplicates
BTo make the list shorter
CTo decide which half of the list to search next
DTo use less memory
What is the time complexity of binary search in terms of number of elements n?
AO(log n)
BO(1)
CO(n log n)
DO(n)
If a list is not sorted, what will happen if you use binary search?
AIt will sort the list first
BIt will always find the target
CIt will find the target faster
DIt may give wrong results
Which of these is a benefit of sorted order besides binary search?
ASlower insertion
BEasier to find minimum and maximum
CMore memory usage
DNo duplicates allowed
How many elements remain to search after the first step of binary search on a list of 16 elements?
A8
B15
C4
D1
Explain why binary search requires a sorted list and how it uses this property to find an element.
Think about how knowing order helps decide where to look next.
You got /4 concepts.
    Describe the difference in efficiency between linear search and binary search and why binary search is faster on large sorted lists.
    Consider how many steps each method takes as the list grows.
    You got /4 concepts.