Skip to content

Commit a3e4421

Browse files
committed
added test_skill in bab 9
1 parent 3466ac5 commit a3e4421

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

bab9_funcrecursive/test_skill/fibbonaci.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Fibbonaci Example
2+
13
def fibbonaci(x):
24
if x == 0:
35
return 0
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Recursive on Binnary Search
2+
3+
def binarySearch(mylist, item):
4+
if len(mylist) == 0:
5+
return False
6+
else:
7+
midpoint = len(mylist) // 2
8+
9+
if mylist[midpoint] == item:
10+
return True
11+
else:
12+
if item < mylist[midpoint]:
13+
return binarySearch(mylist[:midpoint], item)
14+
else:
15+
return binarySearch(mylist[midpoint + 1:], item)
16+
17+
18+
if __name__ == '__main__':
19+
j = []
20+
k = int(input("Enter length of your list: "))
21+
for i in range(k):
22+
l = int(input("element %s of your list: " % (i + 1)))
23+
j.append(l)
24+
j.sort()
25+
print(j)
26+
27+
s = int(input("Find the number : "))
28+
print(binarySearch(j, s))

0 commit comments

Comments
 (0)