📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!

  • google app store apple app store
  • ✖

      Question

      Consider the following Python code snippet for binary

      search:     def binary_search(arr, target):         low = 0         high = len(arr) - 1         while low
      B 2 Correct Answer Incorrect Answer
      C 3 Correct Answer Incorrect Answer
      D 5 Correct Answer Incorrect Answer
      E 6 Correct Answer Incorrect Answer

      Solution

      Initial: low = 0, high = 5     First iteration: mid = (0 + 5) // 2 = 2     arr[2] is 30, which matches the target. The function would return 2.

      Practice Next
      ask-question