What will be the necessary condition to get the desired element from a given…

PYQ Accenture Hiring Assessment 2024

What will be the necessary condition to get the desired element from a given array by using the following algorithms?

If LOC = -1 do ITEM NOT FOUND

Do_Something(DATA, N, ITEM,LOC)

initialize Counter set LOC=0, LOW=0, HI= N-1

[Search for item]

Repeat while LOWs HI

MID = (LOW+HI)/2

IF ITEM = DATA[MID] do

LOC+MID

Return LOC

IF ITEM = DATA [MID}

HI = MID-1

ELSE

LOW = MID+1

  1. A.

    the elements should contain more than one element

  2. B.

    the array should contain more than one element

  3. C.

    The elements is an array should be in the sorted form.

  4. D.

    No pre-condition is required for the algorithm to work

Attempted by 124 students.

Sign up free to check your answer

Sign up free

Explore the full course: Cdac C Cat Complete Preparation

Loading lesson…