• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jan 29th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. def bubble(aList):
2.     for i in range(len(aList)):
3.         for j in range(len(aList)-i-1):
4.             if aList[j]>aList[j+1]:
5.                 temp = aList[j]
6.                 aList[j]=aList[j+1]
7.                 aList[j+1] = temp
8.         print(i)
9.         print(aList)
10.     return aList
11.
12. def binsearch(aList,n):
13.     left = 0
14.     right = len(aList) - 1
15.     found = False
16.     while left <= right and not found:
17.         mid = (left + right)//2
18.         print(mid)
19.         if aList[mid] == n :
20.             found = True
21.         else :
22.             if n < aList[mid]:
23.                 right = mid - 1
24.             else:
25.                 left = mid + 1
26.     return found
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top