Calcul de la complexité d'un algorithme
Bonsoir à tout le monde,
je m'initie au calcul de complexité d'algorithme via divers tuto trouvé sur le net et j'ai un problème pour le calcul de deux de mes algorithmes:
ALGO 1
Code:
1 2 3 4 5 6 7 8 9
|
for i in range(n):
opération
for i in range(n-1):
opération
for j in range(2,n):
for i in range(0,n-1):
if cond 1
if cond 2 |
je trouve :2N-1 + (N*N-5N+6)(O(1))
ALGO 2
Code:
1 2 3 4 5 6
|
for i in range(1,n-1)
while i-j >=0 and i+j <n and ch[i-j] == ch[i+j]:
if cond 1
while i-j >=0 and i+j+1 <n and ch[i-j] == ch[i+1+j]:
if cond 2 |
ici je bloque car je n'ai trouvé aucune précision sur le while
ALGO 3
Code:
1 2 3 4 5 6
|
for i in range(n):
for j in range(i,n):
if(
while i<=j:
if(ch[i]!=ch[j]): |
idem encore une fois une boucle while
Merci à tous ,
Coulbu