Skip to content

apaseg/hactoberfest

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

hactoberfest

Binary Search in python

def binarySearch(array, x, low, high):

# Repeat until the pointers low and high meet each other
while low <= high:

    mid = low + (high - low)//2

    if array[mid] == x:
        return mid

    elif array[mid] < x:
        low = mid + 1

    else:
        high = mid - 1

return -1

array = [3, 4, 5, 6, 7, 8, 9] x = 4

result = binarySearch(array, x, 0, len(array)-1)

if result != -1: print("Element is present at index " + str(result)) else: print("Not found")

// comment

// swaping two numbers

#include using namespace std;

int main() { int a = 5, b = 10, temp;

cout << "Before swapping." << endl;
cout << "a = " << a << ", b = " << b << endl;

temp = a;
a = b;
b = temp;

cout << "\nAfter swapping." << endl;
cout << "a = " << a << ", b = " << b << endl;

return 0;

}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published