Skip to content

Instantly share code, notes, and snippets.

View Momellouky's full-sized avatar
😀
Happy

wannatry Momellouky

😀
Happy
View GitHub Profile
import numpy as np
from sklearn.preprocessing import add_dummy_feature
class LinearRegression:
def __init__(self):
self.X = None
self.y = None
self.theta = None
self.coaf_ = None
@Momellouky
Momellouky / binary_search.py
Created August 25, 2024 16:57
binary search on an ordered array
def binary_search(data, param) -> bool :
found = False # To handle recursive calls
if len(data) == 0 :
return None
if len(data) == 2 :
if data[0] == param or data[1] == param :
return True
@Momellouky
Momellouky / linear_search.py
Created August 25, 2024 16:55
Linear Search on an array
def linear_search(data, param) -> bool :
for el in data :
if el == param : # We found it
return True
return False
if __name__ == '__main__' :
data = [ 7, 10, 3, 1, 66, 6 ]
param = 1 # The integer we are looking for in the array
std::shared_ptr<Type> sp;
Type* ptr = new Type();
sp = ptr ; // compiler error!!!
class Type {
public:
foo();
}
Type::foo(){
// Doing something
}