Chapitre 3 informatique commune Algorithmes de tris
recherche d’un élément dans un tableau On sait que ce problème a un coût linéaire, mais si on prévoit de faire de nombreuses recherches, il peut être intéressant de commencer par trier ces données, car le coût d’une recherche dichotomique est logarithmique
1 Algorithmesdetri
F JUNIER 2012/2013 Chapitre: Algorithmiquepartie2: algorithmesdetri ISN 2 Letriparsélection 2 1 Algorithme Considérons un joueur decartesqui tient danssamain les cartesendésordredesadonne Onsuppose qu’on adéfinisur les cartes
Université Paris Dauphine IUP Génie Mathématique et Informatique
IUP Génie Mathématique et Informatique - Mise à Niveau Informatique RECHERCHE DICHOTOMIQUE DANS UN TABLEAU D'ENTIERS #include /* Programm int main() e de recherche dichotomique d'un élément dans une liste d'entiers */
ISUP-python Récursion
language keywords forbidden lower/UPPER case discrimination ☝ expression with just comas →tuple dictionary collection integer, oat, boolean, string, bytes Identi ers ☺ a toto x7 y_max BigOne ☹ 8y and for x+=3 x-=2 increment ⇔ x= +3 decrement ⇔ x= -2 Conversions for lists, tuples, strings, bytes int("15") → 15
2 Quelquesalgorithmesdetri
On peut améliorer l’algorithme précédent en effectuant une recherche dichotomique de la place de l’élément à insérer dans la tranche qui le précède, puisqu’elle est triée Cela permet de ramener le nombredecomparaisonsàunO(nlog2n),maiscelan’évitepaslesdécalagesd’élémentsdutableau,
Programmation récursive 1 Quest-ce que la - LIPN
3 2 Récursivité simple : recherche dichotomique On stocke des paires (index, objet) dans un tableau Le tableau est rangé par index (des chaînes en ordre alphabétique) L'utilisateur fournit un index et on doit lui renvoyer l'objet associé public class DichoMap {MapObject table[] ; MapObject getObject(String index)
Algorithmes et programmation en Pascal
6 Algorithmes et programmation en Pascal Edouard Thiel I Les variables en Pascal 1 Premiers programmes 1 1 Le programme bonjour Un programme est une suite d’instructions, certaines etan t des mots cl es
Exo7 - Cours de mathématiques
Algorithmes et mathématiques Chapitre 1 Vidéo — partie 1 Premiers pas avec Python Vidéo — partie 2 Ecriture des entiers Vidéo — partie 3 Calculs de sinus, cosinus, tangente
[PDF] organisation d une dsi type
[PDF] manuel de procédures informatiques
[PDF] cyberlux 8
[PDF] organisation d'un service informatique dans une entreprise
[PDF] cyberlux 8 crack
[PDF] exemple dossier exploitation informatique
[PDF] cyberlux 8 full
[PDF] bibliographie de max weber
[PDF] max weber pdf
[PDF] max weber économie et société tome 2 pdf
[PDF] max weber le savant et le politique pdf
[PDF] max weber économie et société fiche de lecture
[PDF] max weber économie et société tome 1 résumé
[PDF] max weber économie et société pdf
ISUP-pythonRécursion
Larécursion•Exempledefactorielle
Larécursion•Exempledefactorielle
6a11aExercises61
Exercise6a5aTheAckermannfunctionc AnmcnmcisdeÞned:Anmcnm=
t u p u l nr1ifm=dAnmt1c1mifm>dandn=d
Anmt1cAnmcnt1mmifm>dandn>da
SeeaWrite afunctionnamed
thatevaluatesAckermannÕ sfunctionaUse yourfunctiontoevaluatecwhichshould be1x5aWhathappens forlarger valuesof and?Solution:
a Exercise6a6aApalindrome isawordthatisspelled thesamebackward andforwardclike ÒnoonÓ andÒredivider ÓaRecursivelycawordisapalindr omeiftheÞrstandlast lettersare thesameand the middleisa palindromea Thefollowingar efunctionsthat takeastringargumentand returnthe Þrstclastc andmiddleletters:WeÕllseehowtheywork inChapter8a
1aType thesefunctionsintoaÞle namedandtestthem outaWhathappens if
youcallwithastring withtwoletters? Oneletter?What abouttheempty stringc whichiswritten andcontainsno letters? xaWrite afunctioncalledthattakesa stringar gumentandr eturnsifit isapalindr omeandotherwiseaRememberthat youcanuse thebuilt.infunction tocheckthe lengthofa stringaSolution:a
Exercise6a7aAnumberc acisapowerof bifitisdivisibleby banda obisa powerofb aW ritea functioncalledthattakesparameters andandreturns ifisapower ofaNote: youwillhave tothinkabout thebase casea Exercise6a8aThegreatest commondivisornGCDmofa andbis thelargest numberthatdivides bothofthem withnor emaindera Onewayto ÞndtheGCD oftwo numbersisbased ontheobservation thatifr isther emainderwhen ais dividedbybctheng cdnacbm=gcdnbcrmaAsa basecasecwe canuse gcd nacdm=aa Retour sur ce qu'on a vu Sequence Containers IndexingBase Types
Python 3 Cheat Sheet
©2012-2015 - Laurent Pointal
License Creative Commons Attribution 4
Latest version on :
0783-192int
9.23-1.7e-60.0float
TrueFalsebool
"One\nTwo" 'I\'m' str """X\tY\tZ1\t2\t3"""
×10
-6 escaped tab escaped new lineMultiline string:
Container Types
list[1,5,9]["x",11,8.9]["mot"][] tuple (1,5,9)11,"y",7.4("mot",)() dict {1:"one",3:"three",2:"two",3.14:"π"} {"key":"value"} set {1,9,3,0} ◾ ordered sequences, fast index access, repeatable values set() ◾ key containers, no a priori order, fast key acces, each key is unique {"key1","key2"}Non modiable values (immutables)
Variables assignment
x=1.2+8+sin(y) y,z,r=9.2,-7.6,0 a...zA...Z_ followed by a...zA...Z_0...9 ◽ diacritics allowed but should be avoided ◽ language keywords forbidden ◽ lower/UPPER case discrimination ☝ expression with just comas →tuple dictionary collection integer, %oat, boolean, string, bytesIdentiers
☺ a toto x7 y_max BigOne ☹ 8y and for x+=3 x-=2 increment ⇔ x=x+3 decrement ⇔ x=x-2Conversions
for lists, tuples, strings, bytes... int("15") → 15 int("3f",16) → 63can specify integer number base in 2 nd parameter int(15.56) → 15truncate decimal part float("-11.24e8") → -1124000000.0 round(15.56,1)→ 15.6rounding to 1 decimal (0 decimal → integer number) bool(x)False for null x, empty container x , None or False x ; True for other x str(x)→ "..."representation string of x for display (cf. formating on the back) chr(64)→'@'ord('@')→64code ↔ char repr(x)→ "..."literal representation string of x bytes([72,9,64]) → b'H\t@' list("abc") → ['a','b','c'] dict([(3,"three"),(1,"one")]) → {1:'one',3:'three'} set(["one","two"]) → {'one','two'} separator str and sequence of str → assembled str ':'.join(['toto','12','pswd']) → 'toto:12:pswd' str splitted on whitespaces → list of str "words with spaces".split() → ['words','with','spaces'] str splitted on separator str → list of str "1,4,8,2".split(",") → ['1','4','8','2'] sequence of one type → list of another type (via comprehension list) [int(x) for x in ('1','29','-3')] → [1,29,-3] type(expression) lst=[10, 20, 30, 40, 50] lst[1]→20 lst[-2]→40 01234-5-4-3-1-2Individual access to items via lst[index] positive index negative index