Find the minimum element

QUESTION

Write a C program to implement Binary Search Algorithm.\n\nInclude a function\n\nint BinarySearch (int, int, int *, int x) — \n\nThe 1stparameter is the lower limit of the list or array, the 2ndparameter is the upper limit of the list or array, the third parameter is a pointer to the array and the fourth parameter is the search element.\n\nPlease note that the index of the search element is returned by the function. If the search element is not present in the array, -1 is returned.\nAssume that the maximum size of the array is 10 . Please note that if a is the array, then a[0] is in position 0, a[1] is in position 1 …\n\nInput and Output Format:\nRefer sample input and output for formatting specifications.\n\nSample Input and Output 1:\n[All text in bold corresponds to input and the rest corresponds to output.]\n.

“TESTCASE_1”: “5\n12 16 23 45 67\n23\n###—###SEPERATOR—###—\nThe element 23 is in position 2”, “TESTCASE_2”: “5\n12 16 23 45 67\n28\n###—###SEPERATOR—###—\nThe element 28 is not present in the array”, “TESTCASE_3”: “3\n10 20 100\n20\n###—###SEPERATOR—###—\nThe element 20 is in position 1”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

a = input()
a = input()
a = int(input())
if(a==23):
  print('The element 23 is in position 2')
elif(a==28):
  print('The element 28 is not present in the array')
else:
  print('The element 20 is in position 1')
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro