Answer to Question #259474 in Python for anu

Question #259474

BINARY(ARRAY,LB,UB,ITEM,LOC) which finds the location LOC where ITEM appears in ARRAY


1
Expert's answer
2021-11-01T01:59:10-0400
# This algorithm finds the location of LOC where ITEM appears in Array
Set DATA[N+1]:=ITEM
Set LOC = 1
Repeat while DATA[LOC]!= ITEM:
  Set LOC := LOC + 1
  [End of loop]
if LOC = N + 1, then:
  Write: ITEM is not in the array DATA
else:
  Write: LOC is the location of ITEM
    Exit

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog