GeekCode
793 subscribers
452 photos
3 videos
7 files
942 links
🍁Cyber Security ❀️
🍁Hacking Resources πŸ‘¨β€πŸ’»

Providing knowledge to people'sπŸ₯€
Nobody gets smaller by sharing knowledge
You can also share your knowledge with us...πŸ™‚πŸ™‚

πŸ“°Promotion/Query - @geekcodevipbot
Download Telegram
This media is not supported in your browser
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
BINARY SEARCH

C++
........

#include<iostream>

using namespace std;

int main()
{
int a[100], n, i, beg, end, mid, item;

cout << "Enter No. of Elements : ";
cin >> n;

cout << "\nEnter Elements in Sorted Order :\n";
for (i = 1; i <= n; i++)
{
cin >> a[i];
}

cout << "\nEnter Item you want to Search : ";
cin >> item;

beg = 1;
end = n;

mid = (beg + end) / 2;

while (beg <= end && a[mid] != item)
{
if (a[mid] < item)
beg = mid + 1;
else
end = mid - 1;

mid = (beg + end) / 2;
}

if (a[mid] == item)
{
cout << "\nElement found at location : " << mid;
}
else
{
cout << "Element not found";
}
return 0;
}

========
Output
========

Enter No. of Elements : 3

Enter Elements in Sorted Order :
2
3
5

Enter Item you want to Search : 3

Element found at location : 2
This media is not supported in your browser
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
@geekcode


Join us guy's πŸ™
BLACK HAT & WHITE HAT HACKERS ...!

WHICH ONE ARE YOU?

SEND FEEDBACK HERE
@mycriX

❣️Share & support us ❣️
βž–βž–
@geekcode βž–βž–
This media is not supported in your browser
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
SQL CHEAT SHEET 😍

READ POST ☝️

❣️SHARE & SUPPORT US ❣️

βž–βž–
@geekcode βž–βž–
Photoshop cheat sheet πŸ€—
..
Read post ☝️


❣️share & support us ❣️

βž–βž–
@geekcode βž–βž–
This media is not supported in your browser
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM