NEW
Font size
WorksheetsBinary Search
Total questions: 12
Worksheet time: 26mins
What does the binary search algorithm do?
It finds an element in an unsorted array.
It searches for an element by comparing it with each element of the array sequentially.
It only works with arrays sorted in descending order
It finds an element in a sorted array by repeatedly dividing the search interval in half.
Why is binary search considered significantly faster than linear search, especially for large datasets?(Почему бинарный поиск считается значительно быстрее линейного поиска, особенно для больших наборов данных?)
Binary search checks every element in the array.(Бинарный поиск проверяет каждый элемент в массиве)
Binary search repeatedly divides the search interval in half, reducing the number of comparisons.(Бинарный поиск повторно делит интервал поиска пополам, уменьшая количество сравнений.)
Binary search works only with unsorted data.(Бинарный поиск работает только с неотсортированными данными.)
Binary search always finds the largest element in the array.(Бинарный поиск всегда находит наибольший элемент в массиве.
)
What is the time complexity of Binary Search?
Best Case: O(n), Worst Case: O(n)
Best Case: O(log n), Worst Case: O(log n)
Best Case: O(1), Worst Case: O(log n)
Best Case: O(n), Worst Case: O(1)
Which of the following are advantages of Binary Search
Efficiency: Faster than linear search, but inconsistent performance.
Efficiency: Much faster than linear search for large datasets, Predictable Performance: Consistent O(log n) time complexity
Slow for large datasets, Unpredictable performance.
Efficiency: As fast as linear search, Predictable Performance: O(n) time complexity.
Which of the following are disadvantages of Binary Search?
Requires Sorted Data, Complexity in Implementation, Not Suitable for Linked Lists.
Requires Sorted Data, Simpler Implementation, Works well with Linked Lists.
Does not require Sorted Data, Complexity in Implementation, Works well with Linked Lists.
Requires Sorted Data, Easier to implement, Can be used with Linked Lists.
What is the primary condition that must be met for binary search to function properly?
(Какое основное условие должно быть выполнено, чтобы бинарный поиск работал корректно?)
The array must be unsorted. (Массив должен быть неотсортированным.)
The array must be sorted before performing binary search. (Массив должен быть отсортирован перед выполнением бинарного поиска.
Binary search can work on any data, sorted or not. (Бинарный поиск может работать с любыми данными, отсортированными или нет.)
The array must contain only unique elements. (Массив должен содержать только уникальные элементы.)
What is the main challenge when adjusting the low, high, and mid indices in binary search?
(Какая основная трудность при корректировке индексов low, high и mid в бинарном поиске?)
Sorting the array after each iteration. (Сортировка массива после каждой итерации.)
It is important to minimize the number of elements in the array. (Важно минимизировать количество элементов в массиве.)
Ensuring the array is not too large. (Убедиться, что массив не слишком велик.)
Properly adjusting the indices at each step to avoid infinite loops or errors. (Правильная корректировка индексов на каждом шаге, чтобы избежать бесконечных циклов или ошибок.)
Which of the following cases is important to test when using binary search?
(Какой из следующих случаев важно протестировать при использовании бинарного поиска?)
Test on a small unsorted array. (Тестировать на небольшом неотсортированном массиве.)
Test on an array where the target is not found. (Тестировать на массиве, где цель не найдена.)
Test on an array with random unsorted data. (Тестировать на массиве с случайными неотсортированными данными.)
Test using the linear search algorithm. (Тестировать с использованием алгоритма линейного поиска.)
What is the correct way to calculate mid to avoid integer overflow in binary search?
(Как правильно вычислить mid, чтобы избежать переполнения целочисленного типа при бинарном поиске?)
mid = (low + high) / 2
(mid = (low + high) / 2)
mid = low high / 2
(mid = low high / 2)
mid = low + (high - low) / 2
(mid = low + (high - low) / 2)
mid = (low + high) 2
(mid = (low + high) 2)
What issue should be considered when applying binary search to arrays of floating-point numbers?
(Какую проблему следует учитывать при применении бинарного поиска к массивам с числами с плавающей точкой?)
Floating-point numbers are always sorted.
(Числа с плавающей точкой всегда отсортированы.)
Floating-point numbers have precision issues.
(Числа с плавающей точкой имеют проблемы с точностью.)
Binary search cannot be applied to floating-point numbers.
(Бинарный поиск не может быть применен к числам с плавающей точкой.)
Floating-point numbers are not compatible with binary search.
(Числа с плавающей точкой несовместимы с бинарным поиском.)
Why must the array be sorted for binary search to work correctly?
(Почему массив должен быть отсортирован для корректной работы бинарного поиска?)
To ensure that comparisons with the middle element can reliably determine which half of the array to eliminate.
(Чтобы гарантировать, что сравнения с центральным элементом могут надежно определить, какую половину массива исключить.)
To reduce the number of iterations needed for the search.
(Чтобы уменьшить количество итераций, необходимых для поиска.)
To make the search process faster.
(Чтобы ускорить процесс поиска.
To allow for faster access to the array elements.
(Чтобы позволить более быстрый доступ к элементам массива.)
What is the result of using binary search on an unsorted array?
(Что произойдет при использовании бинарного поиска на неотсортированном массиве?)
The algorithm will return incorrect results or fail to find the target element.
(Алгоритм вернет неправильные результаты или не найдет целевой элемент.)
The algorithm will still find the element but with more iterations.
(Алгоритм все равно найдет элемент, но потребуется больше итераций.)
The search will be slower but still accurate.
(Поиск будет медленнее, но все равно точным.)
The algorithm will give the correct results even without sorting the array.
(Алгоритм даст правильные результаты, даже если массив не отсортирован.)
