Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. def rech_dichoto(x,L):
  2.     n=len(L)
  3.     p=1
  4.     while n>p:
  5.         m=int((p+n)/2)
  6.         if x==L[m]:
  7.             return(m)
  8.         elif x<L[m]:
  9.             n=m-1
  10.         else:p=m+1
  11.  
  12.            
  13. def trisel(L):
  14.     n=len(L)
  15.     for i in range(n-1):
  16.         x=l[i]
  17.         for j in range(i+1,n):
  18.             if L[j]<x:
  19.                 L[j],x=x,l[j]
  20.         L[i]=x
  21.     return(l)
  22.  
  23.  
  24. def trirap(l):
  25.     if l==[]:
  26.         return([])
  27.     else:
  28.         pivot=l[0]
  29.         l1=[]
  30.         l2=[]
  31.         for x in l[1:]:
  32.             if x<pivot:
  33.                 l1.append(x)
  34.             else:
  35.                 l2.append(x)
  36.         return(quicksort(l1)+[pivot]+quicksort(l2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement