[{"data":1,"prerenderedAt":851},["ShallowReactive",2],{"article-fr-\u002Fdsa\u002Fquick-sort":3,"article-sibling-fr-\u002Fdsa\u002Fquick-sort":466,"surround-fr-\u002Fdsa\u002Fquick-sort":832,"related-fr-\u002Fdsa\u002Fquick-sort":839},{"id":4,"title":5,"body":6,"date":452,"description":453,"extension":454,"img":455,"meta":456,"navigation":193,"path":457,"seo":458,"slug":459,"stem":460,"tags":461,"topics":463,"__hash__":465},"content\u002F1.dsa\u002F3.quick-sort.fr.md","Maîtriser l'algorithme Quick Sort en Python : un guide complet",{"type":7,"value":8,"toc":441},"minimark",[9,14,23,27,30,34,37,42,45,48,51,54,57,60,63,67,70,77,80,160,163,167,170,384,387,391,394,420,427,431,434,437],[10,11,13],"h2",{"id":12},"introduction","Introduction",[15,16,17,18,22],"p",{},"Quicksort est un algorithme de tri efficace qui utilise une approche ",[19,20,21],"strong",{},"diviser pour régner","\npour organiser les données. Simpliste en apparence, ce concept est fondamental pour les\ncomplexités de programmation comme la recherche dans des fichiers, la compression de données et\nle pathfinding. Pour optimiser la vitesse et la qualité du process, il faut prendre en compte le\ntemps d'exécution associé au choix d'une méthode de tri. Dans le cas de Quicksort, le pire des\ncas est lent, mais ses cas moyen et meilleur restent relativement rapides.",[10,24,26],{"id":25},"cest-quoi-lalgorithme-quick-sort","C'est quoi l'algorithme Quick Sort",[15,28,29],{},"Imagine que tu ranges une chambre en désordre — Quick Sort, c'est arranger les éléments d'une\nliste de manière similaire. On va voir comment cet algorithme sépare, trie et recombine les\néléments pour produire une liste bien rangée.",[10,31,33],{"id":32},"comment-fonctionne-le-tri-par-insertion","Comment fonctionne le tri par insertion",[15,35,36],{},"Deux versions : pour un enfant, et pour un adulte.",[38,39,41],"h3",{"id":40},"expliqué-à-un-enfant","Expliqué à un enfant",[15,43,44],{},"Imagine que tu as une ligne de cartes numérotées toutes mélangées, et qu'il faut les remettre en\nordre. On va utiliser une méthode spéciale appelée le « tri par insertion ».",[15,46,47],{},"Imagine que tu joues à un jeu où tu as quelques cartes en main et que tu veux les ranger du plus\npetit au plus grand. Tu commences par regarder la première carte et tu fais comme si elle était\ndéjà bien placée (parce qu'une seule carte est déjà ordonnée).",[15,49,50],{},"Tu prends la deuxième carte et tu la compares à la première. Si la deuxième est plus petite, tu\nla mets avant la première. Si elle est plus grande, tu la laisses où elle est.",[15,52,53],{},"Puis tu prends la troisième carte et tu la compares aux deux premières. Si elle est plus petite\nque les deux, tu lui trouves une place avant elles. Si elle est plus grande qu'une seule, tu la\nmets là. Et si elle est plus grande que les deux, tu la laisses où elle est.",[15,55,56],{},"Tu continues comme ça pour chaque carte. À chaque fois, tu regardes la carte, tu la compares à\ncelles déjà rangées, et tu lui trouves la bonne place. Tu continues jusqu'à ce que toutes les\ncartes soient rangées.",[15,58,59],{},"Comme ça, tu tries les cartes en « insérant » chaque carte à la bonne place parmi celles déjà\nrangées. C'est un peu comme placer les pièces d'un puzzle au bon endroit pour compléter l'image !",[15,61,62],{},"Le tri par insertion peut prendre un peu plus de temps si tu as beaucoup de cartes, mais il est\nparfait quand tu n'en as que peu, ou quand certaines sont déjà presque à la bonne place. C'est\nune façon patiente de trier qui marche bien pour les petites quantités.",[38,64,66],{"id":65},"expliqué-à-un-adulte","Expliqué à un adulte",[15,68,69],{},"Voyons comment le tri par insertion fonctionne avec un exemple pas à pas. Soit la liste non\ntriée suivante :",[15,71,72,73],{},"Liste non triée : ",[74,75,76],"span",{},"5, 2, 9, 3, 1",[15,78,79],{},"Voici comment l'algorithme la trie :",[81,82,83,90,114,132,152],"ol",{},[84,85,86,89],"li",{},[19,87,88],{},"Initialisation"," : le premier élément, 5, est considéré comme la portion triée initiale.",[84,91,92,95,96],{},[19,93,94],{},"Itération sur la portion non triée"," :",[97,98,99,102,105,108],"ul",{},[84,100,101],{},"On prend le deuxième élément, 2, comme « clé » courante.",[84,103,104],{},"On compare la clé (2) à l'élément de la portion triée (5). Comme 5 > 2, on décale 5 d'une\nposition vers la droite.",[84,106,107],{},"On insère la clé (2) à la bonne position dans la portion triée, c'est-à-dire en première\nposition.",[84,109,110,111],{},"La liste devient : ",[74,112,113],{},"2, 5, 9, 3, 1",[84,115,116,95,119],{},[19,117,118],{},"Suite de l'itération",[97,120,121,124,127],{},[84,122,123],{},"On prend le troisième élément, 9, comme clé.",[84,125,126],{},"On compare la clé (9) au dernier élément de la portion triée (5). Comme 5 \u003C 9, la clé reste\nà sa place.",[84,128,129,130],{},"La liste reste inchangée : ",[74,131,113],{},[84,133,134,95,136],{},[19,135,118],{},[97,137,138,141,144,147],{},[84,139,140],{},"On prend le cinquième élément, 1, comme clé.",[84,142,143],{},"On compare la clé (1) aux éléments de la portion triée (9, 5, 3, 2). On décale tous ces\néléments d'une position vers la droite pour faire de la place à la clé.",[84,145,146],{},"On insère la clé (1) à la bonne position dans la portion triée, c'est-à-dire en première\nposition.",[84,148,110,149],{},[74,150,151],{},"1, 2, 3, 5, 9",[84,153,154,157,158],{},[19,155,156],{},"Fin"," : tous les éléments ont été parcourus et insérés à leurs bonnes positions. La liste\nest maintenant entièrement triée : ",[74,159,151],{},[15,161,162],{},"En substance, le tri par insertion prend un élément à la fois depuis la portion non triée, le\ncompare aux éléments de la portion triée, et l'insère à la bonne position. La portion triée\ngrandit à chaque itération jusqu'à ce que tous les éléments soient dans leur ordre final. Ce\nn'est pas l'algorithme de tri le plus rapide, mais sa simplicité et son adéquation aux petits\njeux de données en font un outil précieux dans certains scénarios.",[10,164,166],{"id":165},"implémentation-en-python","Implémentation en Python",[15,168,169],{},"Voici une implémentation pas à pas du tri par insertion en Python, qui réduit le nombre\nd'assignations dans la boucle interne en utilisant une seule assignation après la boucle. Cela\névite les assignations inutiles quand les éléments sont déjà à leurs bonnes positions.",[171,172,178],"pre",{"className":173,"code":174,"filename":175,"language":176,"meta":177,"style":177},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","from typing import List\n\ndef insertion_sort(arr: List[int]) -> List[int]:\n    \"\"\"\n    Sorts a list of integers in ascending order using the Insertion Sort algorithm.\n\n    Args:\n        arr (List[int]): The list of integers to be sorted.\n\n    Returns:\n            List[int]: The sorted list of integers.\n    \"\"\"\n    for i in range(1, len(arr)):\n        key = arr[i]  # Current element to be inserted into the sorted portion\n        j = i - 1     # Index of the last element in the sorted portion\n\n        # Compare the key with elements in the sorted portion and shift as needed\n        while j >= 0 and key \u003C arr[j]:\n            arr[j + 1] = arr[j]\n            j -= 1\n\n        arr[j + 1] = key  # Insert the key in its correct position\n\n    return arr\n\ndef main():\n    # Input collection from the user\n    input_str = input(\"Enter a list of integers separated by a commas: \")\n    input_list = [int(x) for x in input_str.split(',')]\n\n    # Print sorted collection\n    print(*insertion_sort(input_list), sep=\",\")\n\nif __name__ == \"__main__\":\n    main()\n","insertion_sort.py","python","",[179,180,181,188,195,201,207,213,218,224,230,235,241,247,252,258,264,270,275,281,287,293,299,304,310,315,321,326,332,338,344,350,355,361,367,372,378],"code",{"__ignoreMap":177},[74,182,185],{"class":183,"line":184},"line",1,[74,186,187],{},"from typing import List\n",[74,189,191],{"class":183,"line":190},2,[74,192,194],{"emptyLinePlaceholder":193},true,"\n",[74,196,198],{"class":183,"line":197},3,[74,199,200],{},"def insertion_sort(arr: List[int]) -> List[int]:\n",[74,202,204],{"class":183,"line":203},4,[74,205,206],{},"    \"\"\"\n",[74,208,210],{"class":183,"line":209},5,[74,211,212],{},"    Sorts a list of integers in ascending order using the Insertion Sort algorithm.\n",[74,214,216],{"class":183,"line":215},6,[74,217,194],{"emptyLinePlaceholder":193},[74,219,221],{"class":183,"line":220},7,[74,222,223],{},"    Args:\n",[74,225,227],{"class":183,"line":226},8,[74,228,229],{},"        arr (List[int]): The list of integers to be sorted.\n",[74,231,233],{"class":183,"line":232},9,[74,234,194],{"emptyLinePlaceholder":193},[74,236,238],{"class":183,"line":237},10,[74,239,240],{},"    Returns:\n",[74,242,244],{"class":183,"line":243},11,[74,245,246],{},"            List[int]: The sorted list of integers.\n",[74,248,250],{"class":183,"line":249},12,[74,251,206],{},[74,253,255],{"class":183,"line":254},13,[74,256,257],{},"    for i in range(1, len(arr)):\n",[74,259,261],{"class":183,"line":260},14,[74,262,263],{},"        key = arr[i]  # Current element to be inserted into the sorted portion\n",[74,265,267],{"class":183,"line":266},15,[74,268,269],{},"        j = i - 1     # Index of the last element in the sorted portion\n",[74,271,273],{"class":183,"line":272},16,[74,274,194],{"emptyLinePlaceholder":193},[74,276,278],{"class":183,"line":277},17,[74,279,280],{},"        # Compare the key with elements in the sorted portion and shift as needed\n",[74,282,284],{"class":183,"line":283},18,[74,285,286],{},"        while j >= 0 and key \u003C arr[j]:\n",[74,288,290],{"class":183,"line":289},19,[74,291,292],{},"            arr[j + 1] = arr[j]\n",[74,294,296],{"class":183,"line":295},20,[74,297,298],{},"            j -= 1\n",[74,300,302],{"class":183,"line":301},21,[74,303,194],{"emptyLinePlaceholder":193},[74,305,307],{"class":183,"line":306},22,[74,308,309],{},"        arr[j + 1] = key  # Insert the key in its correct position\n",[74,311,313],{"class":183,"line":312},23,[74,314,194],{"emptyLinePlaceholder":193},[74,316,318],{"class":183,"line":317},24,[74,319,320],{},"    return arr\n",[74,322,324],{"class":183,"line":323},25,[74,325,194],{"emptyLinePlaceholder":193},[74,327,329],{"class":183,"line":328},26,[74,330,331],{},"def main():\n",[74,333,335],{"class":183,"line":334},27,[74,336,337],{},"    # Input collection from the user\n",[74,339,341],{"class":183,"line":340},28,[74,342,343],{},"    input_str = input(\"Enter a list of integers separated by a commas: \")\n",[74,345,347],{"class":183,"line":346},29,[74,348,349],{},"    input_list = [int(x) for x in input_str.split(',')]\n",[74,351,353],{"class":183,"line":352},30,[74,354,194],{"emptyLinePlaceholder":193},[74,356,358],{"class":183,"line":357},31,[74,359,360],{},"    # Print sorted collection\n",[74,362,364],{"class":183,"line":363},32,[74,365,366],{},"    print(*insertion_sort(input_list), sep=\",\")\n",[74,368,370],{"class":183,"line":369},33,[74,371,194],{"emptyLinePlaceholder":193},[74,373,375],{"class":183,"line":374},34,[74,376,377],{},"if __name__ == \"__main__\":\n",[74,379,381],{"class":183,"line":380},35,[74,382,383],{},"    main()\n",[15,385,386],{},"Cette optimisation réduit le nombre d'assignations dans la boucle interne, ce qui peut améliorer\nlégèrement la performance, surtout sur de plus grands jeux de données. Il faut noter que la\ncomplexité temporelle fondamentale de l'algorithme reste la même.",[10,388,390],{"id":389},"applications-du-tri-par-insertion","Applications du tri par insertion",[15,392,393],{},"En pratique, le tri à bulles est rarement utilisé en production à cause de son inefficacité par\nrapport à d'autres algorithmes. Il garde quelques cas d'usage limités et reste précieux sur le\nplan pédagogique :",[81,395,396,402,408,414],{},[84,397,398,401],{},[19,399,400],{},"Apprentissage"," : utilisé en cours d'algorithmique pour introduire les concepts de tri. Sa\nsimplicité aide les débutants à comprendre.",[84,403,404,407],{},[19,405,406],{},"Petits jeux de données"," : si tu n'as que très peu d'éléments à trier, le tri à bulles\nreste acceptable.",[84,409,410,413],{},[19,411,412],{},"Données déjà presque triées"," : si tes données sont déjà majoritairement triées, le côté\nadaptatif du tri à bulles peut convenir.",[84,415,416,419],{},[19,417,418],{},"Tremplin vers d'autres algorithmes"," : c'est un bon point de départ avant d'attaquer des\ntechniques plus complexes.",[15,421,422,423,426],{},"Pour la majorité des cas réels — surtout sur de grandes données — on préfère Quick Sort, Merge\nSort ou les fonctions de tri intégrées au langage (par ex. ",[179,424,425],{},"sorted()"," en Python).",[10,428,430],{"id":429},"conclusion","Conclusion",[15,432,433],{},"Dans un monde captivé par la vitesse et la complexité de divers algorithmes de tri, le tri par\ninsertion brille comme un symbole d'élégance et de simplicité. Ce n'est pas l'option la plus\nrapide pour de grandes données, mais ses qualités uniques en font un ajout précieux à la boîte à\noutils de tout développeur. La prochaine fois que tu auras une liste modeste à trier, pense au\nhéros discret des algorithmes de tri — le tri par insertion.",[15,435,436],{},"Souviens-toi : maîtriser les bases mène souvent à une compréhension plus profonde et à une plus\ngrande appréciation des complexités qui sous-tendent le monde des algorithmes. Bon code !",[438,439,440],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":177,"searchDepth":190,"depth":190,"links":442},[443,444,445,449,450,451],{"id":12,"depth":190,"text":13},{"id":25,"depth":190,"text":26},{"id":32,"depth":190,"text":33,"children":446},[447,448],{"id":40,"depth":197,"text":41},{"id":65,"depth":197,"text":66},{"id":165,"depth":190,"text":166},{"id":389,"depth":190,"text":390},{"id":429,"depth":190,"text":430},"2023-07-06","Plonge dans le monde des algorithmes de tri avec notre guide approfondi sur le Quick Sort en Python. Apprends le fonctionnement interne de cette technique de tri efficace, pas à pas. Stratégies d'implémentation, bonnes pratiques, et astuces d'optimisation pour intégrer ça facilement dans tes projets.","md","https:\u002F\u002Fres.cloudinary.com\u002Fdpdwhd6ka\u002Fimage\u002Fupload\u002Fv1691560968\u002FBlog\u002Farticles\u002Falgorithms\u002Fbolohyzwbz34pedr1zpp.png",{},"\u002Fdsa\u002Fquick-sort.fr",{"title":5,"description":453},"mastering-the-quick-sort-algorithm-in-python","1.dsa\u002F3.quick-sort.fr",[462],"Algorithms",[464],"dsa","IUOJJBGYFqiT4PunVEOXYFkR9eemzFC0DIfKtttVjn4",{"id":467,"title":468,"body":469,"date":452,"description":824,"extension":454,"img":455,"meta":825,"navigation":193,"path":826,"seo":827,"slug":459,"stem":828,"tags":829,"topics":830,"__hash__":831},"content\u002F1.dsa\u002F3.quick-sort.md","Mastering the Quick Sort Algorithm in Python: A Comprehensive Guide",{"type":7,"value":470,"toc":813},[471,473,476,480,483,487,490,494,497,500,503,506,509,512,515,519,522,527,530,606,609,613,620,764,767,771,774,800,803,805,808,811],[10,472,13],{"id":12},[15,474,475],{},"Quicksort is an efficient sorting algorithm that employs a divide-and-conquer approach to arrange data. Simplistic in\nnature, this concept is fundamental for programming complexities like file searches, data compression, and pathfinding.\nTo optimize the speed and quality of the process, it’s important to acknowledge the running time associated with\nselecting a\nsorting method. In this instance, Quicksort shows a slow worst-case running time, but its average and best-case is\nrelatively speedy.",[10,477,479],{"id":478},"what-is-the-quick-sort-algorithm","What is the Quick Sort Algorithm",[15,481,482],{},"Imagine tidying up a messy room – Quick Sort is like arranging elements in a list in a similar manner. We'll explore how\nthis algorithm splits, sorts, and combines elements to create a neat, organized list.",[10,484,486],{"id":485},"how-insertion-sort-works","How Insertion Sort Works",[15,488,489],{},"Let's have two versions: for a child and for adults",[38,491,493],{"id":492},"explaining-to-a-child","Explaining to a child",[15,495,496],{},"Imagine you have a line of numbered cards, and they're all mixed up and need to be in order. We're going to use a\nspecial way to put them in the right order, and it's called the \"Insertion Sort.\"",[15,498,499],{},"Imagine you're playing a game where you have a few cards in your hand, and you want to put them in order from the\nsmallest number to the biggest number. You start by looking at the first card and pretend it's already in the right\nplace (because one card is already in order).",[15,501,502],{},"Now, you pick the second card and compare it to the first card. If the second card is smaller, you put it before the\nfirst card. If it's bigger, you leave it where it is.",[15,504,505],{},"Then, you take the third card and compare it to the first two cards. If it's smaller than both of them, you find a spot\nfor it before the other cards. If it's bigger than one of them, you put it there. And if it's bigger than both, you\nleave it where it is.",[15,507,508],{},"You keep doing this for every card in your hand. Each time, you look at the card, compare it to the cards that are\nalready in order, and find the right spot for it. You keep doing this until all your cards are in order.",[15,510,511],{},"This way, you're sorting the cards by \"inserting\" each card in the right place among the cards that are already in\norder. It's like putting puzzle pieces in the right spots to complete a picture!",[15,513,514],{},"Insertion Sort might take a bit longer if you have many cards, but it's perfect when you have only a few cards or\nwhen some of them are already close to being in the right order. It's like a patient way of sorting that works nicely\nfor smaller things.",[38,516,518],{"id":517},"explaining-to-an-adult","Explaining to an adult",[15,520,521],{},"Let's walk through how the Insertion Sort algorithm works using a step-by-step example. Consider the following unsorted\nlist of integers:",[15,523,524,525],{},"Unsorted List: ",[74,526,76],{},[15,528,529],{},"Here's how the Insertion Sort algorithm would sort this list:",[81,531,532,538,560,578,598],{},[84,533,534,537],{},[19,535,536],{},"Initialization",": The first element, 5, is considered as the initially sorted portion.",[84,539,540,543,544],{},[19,541,542],{},"Iterating through the Unsorted Portion",":",[97,545,546,549,552,555],{},[84,547,548],{},"Take the second element, 2, as the current \"key.\"",[84,550,551],{},"Compare the key (2) with the element in the sorted portion (5). Since 5 > 2, shift 5 one positions to the right.",[84,553,554],{},"Now, insert the key (2) into the correct position in the sorted portion, which is the first position.",[84,556,557,558],{},"The list becomes: ",[74,559,113],{},[84,561,562,543,565],{},[19,563,564],{},"Continuing the iteration",[97,566,567,570,573],{},[84,568,569],{},"Take the third element, 9, as the key.",[84,571,572],{},"Compare the key (9) with the last element in the sorted portion (5). Since 5 \u003C 9, the key remains in its position.",[84,574,575,576],{},"The list remains unchanged: ",[74,577,113],{},[84,579,580,543,583],{},[19,581,582],{},"Still continuing the iteration",[97,584,585,588,591,594],{},[84,586,587],{},"Take the fifth element, 1, as the key.",[84,589,590],{},"Compare the key (1) with the elements in the sorted portion (9, 5, 3, 2).\nShift all these elements one position to\nthe right to make space for the key.",[84,592,593],{},"Insert the key (1) into the correct position in the sorted portion, which is the first position.",[84,595,557,596],{},[74,597,151],{},[84,599,600,603,604],{},[19,601,602],{},"Completion",": All elements have been iterated over and inserted into their correct positions. The list is now fully\nsorted: ",[74,605,151],{},[15,607,608],{},"In essence, Insertion Sort works by taking one element at a time from the unsorted portion, comparing it with the\nelements in the sorted portion, and inserting it into the correct position. The sorted portion expands with each\niteration until all elements are in their correct sorted order. While not the fastest sorting algorithm, Insertion\nSort's simplicity and suitability for small datasets make it a valuable tool in certain scenarios.",[10,610,612],{"id":611},"implementation-using-python","Implementation using Python",[15,614,615,616,619],{},"Here's a simple step-by-step implementation of the ",[19,617,618],{},"Insertion Sort"," algorithm in Python\nwhich involves reducing the number of assignments inside the inner loop by using a single assignment after the loop.\nThis would avoid unnecessary assignments when elements are already in their correct positions.",[171,621,622],{"className":173,"code":174,"filename":175,"language":176,"meta":177,"style":177},[179,623,624,628,632,636,640,644,648,652,656,660,664,668,672,676,680,684,688,692,696,700,704,708,712,716,720,724,728,732,736,740,744,748,752,756,760],{"__ignoreMap":177},[74,625,626],{"class":183,"line":184},[74,627,187],{},[74,629,630],{"class":183,"line":190},[74,631,194],{"emptyLinePlaceholder":193},[74,633,634],{"class":183,"line":197},[74,635,200],{},[74,637,638],{"class":183,"line":203},[74,639,206],{},[74,641,642],{"class":183,"line":209},[74,643,212],{},[74,645,646],{"class":183,"line":215},[74,647,194],{"emptyLinePlaceholder":193},[74,649,650],{"class":183,"line":220},[74,651,223],{},[74,653,654],{"class":183,"line":226},[74,655,229],{},[74,657,658],{"class":183,"line":232},[74,659,194],{"emptyLinePlaceholder":193},[74,661,662],{"class":183,"line":237},[74,663,240],{},[74,665,666],{"class":183,"line":243},[74,667,246],{},[74,669,670],{"class":183,"line":249},[74,671,206],{},[74,673,674],{"class":183,"line":254},[74,675,257],{},[74,677,678],{"class":183,"line":260},[74,679,263],{},[74,681,682],{"class":183,"line":266},[74,683,269],{},[74,685,686],{"class":183,"line":272},[74,687,194],{"emptyLinePlaceholder":193},[74,689,690],{"class":183,"line":277},[74,691,280],{},[74,693,694],{"class":183,"line":283},[74,695,286],{},[74,697,698],{"class":183,"line":289},[74,699,292],{},[74,701,702],{"class":183,"line":295},[74,703,298],{},[74,705,706],{"class":183,"line":301},[74,707,194],{"emptyLinePlaceholder":193},[74,709,710],{"class":183,"line":306},[74,711,309],{},[74,713,714],{"class":183,"line":312},[74,715,194],{"emptyLinePlaceholder":193},[74,717,718],{"class":183,"line":317},[74,719,320],{},[74,721,722],{"class":183,"line":323},[74,723,194],{"emptyLinePlaceholder":193},[74,725,726],{"class":183,"line":328},[74,727,331],{},[74,729,730],{"class":183,"line":334},[74,731,337],{},[74,733,734],{"class":183,"line":340},[74,735,343],{},[74,737,738],{"class":183,"line":346},[74,739,349],{},[74,741,742],{"class":183,"line":352},[74,743,194],{"emptyLinePlaceholder":193},[74,745,746],{"class":183,"line":357},[74,747,360],{},[74,749,750],{"class":183,"line":363},[74,751,366],{},[74,753,754],{"class":183,"line":369},[74,755,194],{"emptyLinePlaceholder":193},[74,757,758],{"class":183,"line":374},[74,759,377],{},[74,761,762],{"class":183,"line":380},[74,763,383],{},[15,765,766],{},"This optimization reduces the number of assignments within the inner loop, which could lead to slightly improved\nperformance, especially for larger datasets. However, it's important to note that the fundamental time complexity of the\nalgorithm remains the same.",[10,768,770],{"id":769},"insertion-sort-in-real-world-applications","Insertion Sort in real world applications",[15,772,773],{},"In the real world, Bubble Sort is rarely used for practical applications due to its inefficiency compared to other\nsorting algorithms. However, it still has some limited use cases and can be valuable for educational purposes. Here are\na few scenarios where Bubble Sort might be used:",[81,775,776,782,788,794],{},[84,777,778,781],{},[19,779,780],{},"Educational Purposes",": Bubble Sort is often used in programming courses to teach basic sorting concepts. Its\nsimple\nimplementation helps beginners understand how sorting algorithms work.",[84,783,784,787],{},[19,785,786],{},"Small Datasets",": If you have a tiny number of items to sort, Bubble Sort might be acceptable since its\nperformance issues are not as pronounced with small data sets.",[84,789,790,793],{},[19,791,792],{},"Already Partially Sorted Data",": If you're dealing with data that is already mostly sorted, Bubble Sort's adaptive\nnature (it becomes more efficient with fewer swaps as it progresses) might make it a viable choice.",[84,795,796,799],{},[19,797,798],{},"Learning Algorithms",": Bubble Sort can be used as a stepping stone to learn about other, more efficient sorting\nalgorithms. It's a good starting point before moving on to more complex techniques.",[15,801,802],{},"However, for the most practical scenarios, especially those involving larger data sets, you would prefer more efficient\nsorting algorithms like Quick Sort, Merge Sort,\nor the built-in sorting functions provided by programming languages (e.g., sorted() in Python).\nThese algorithms offer significantly better performance and are better suited for real-world\napplications where efficiency matters.",[10,804,430],{"id":429},[15,806,807],{},"In a world captivated by the speed and complexity of various sorting algorithms, the Insertion Sort Algorithm shines as\na symbol of elegance and simplicity. While it might not be the fastest option for large datasets, its unique qualities\nmake it a valuable addition to any programmer's toolbox. So, the next time you're faced with a modestly sized list to\nsort, consider the unassuming hero of sorting algorithms - the Insertion Sort.",[15,809,810],{},"Remember, mastering the basics can often lead to deeper insights and a greater appreciation for the complexities that\nunderlie the world of algorithms. Happy coding!",[438,812,440],{},{"title":177,"searchDepth":190,"depth":190,"links":814},[815,816,817,821,822,823],{"id":12,"depth":190,"text":13},{"id":478,"depth":190,"text":479},{"id":485,"depth":190,"text":486,"children":818},[819,820],{"id":492,"depth":197,"text":493},{"id":517,"depth":197,"text":518},{"id":611,"depth":190,"text":612},{"id":769,"depth":190,"text":770},{"id":429,"depth":190,"text":430},"Dive into the world of sorting data structure algorithms with our in-depth guide on the Quick Sort algorithm in Python. Learn the inner workings of this efficient sorting technique, step by step. Explore implementation strategies, best practices, and performance optimization tips for seamless integration into your projects",{},"\u002Fdsa\u002Fquick-sort",{"title":468,"description":824},"1.dsa\u002F3.quick-sort",[462],[464],"_cPc4qgLl5CNHztz1uO0k7EicPCHqGIsjp_ebNUxqhg",[833,836],{"title":834,"path":835},"Trier des listes efficacement : maîtriser l'algorithme de tri par insertion en Python","\u002Fdsa\u002Finsertion-sort.fr",{"title":837,"path":838},"Maîtriser NestJS : ton guide ultime du développement backend moderne","\u002Fbackend\u002Fnest-js\u002Fintroducing-nest-js.fr",[840,847],{"path":841,"title":842,"description":843,"date":844,"tags":845,"topics":846},"\u002Fdsa\u002Fbuble-sort.fr","Le tri à bulles dévoilé avec Python","Plonge dans les fondamentaux de l'algorithme de tri à bulles en Python et découvre une approche directe du tri. Cet article t'accompagne dans le fonctionnement interne du bubble sort, présente des exemples de code concrets et met en lumière ses forces et ses limites en pratique.","2023-08-09",[462],[464],{"path":835,"title":834,"description":848,"date":452,"tags":849,"topics":850},"Découvre la puissance de l'algorithme de tri par insertion en Python et apprends à trier des listes efficacement pour une meilleure organisation des données. Implémentation pas à pas, exemples pratiques, et astuces pour optimiser la performance.",[462],[464],1780074488764]