题目
题目

IS 4485-001 Fall 2025 Final Exam

单项选择题

Which of these Python code snippets correctly computes the middle index in binary search?

选项
A.mid = (low + high) % 2
B.mid = (low + high) / 2
C.mid = (low - high) // 2
D.mid = (low * high) // 2
E.mid = (high - low) * 2
F.mid = (low + high) // 2
查看解析

查看解析

标准答案
Please login to view
思路分析
Question restatement: Which of these Python code snippets correctly computes the middle index in binary search? Option A: mid = (low + high) % 2 This uses the modulus operator with 2. It does not compute a middle index; it yields either 0 or 1 depending on the parity of the sum. Therefore it cannot be the correct middle index for a binary search. Option B: mid = (low + high) / 2 Here, the division operator / in Pyt......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!