From bb4cb7a4d257c4e2734587ef575aa77e52c91729 Mon Sep 17 00:00:00 2001 From: Cleo Aguiar Date: Thu, 8 Aug 2019 14:19:09 -0300 Subject: [PATCH] update translation insertion-sort (#36554) fix: images link add: markdown identifier to code language --- .../sorting-algorithms/insertion-sort/index.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/guide/portuguese/algorithms/sorting-algorithms/insertion-sort/index.md b/guide/portuguese/algorithms/sorting-algorithms/insertion-sort/index.md index 98cb849166..0c464400fd 100644 --- a/guide/portuguese/algorithms/sorting-algorithms/insertion-sort/index.md +++ b/guide/portuguese/algorithms/sorting-algorithms/insertion-sort/index.md @@ -31,6 +31,7 @@ Passo 1 : Passo 2 : ![[3 8 5 1 4 2]](https://github.com/blulion/freecodecamp-resource/blob/master/insertion_sort/2.png?raw=true) + ``` key = 5 //2nd index @@ -42,6 +43,7 @@ Passo 2 : Etapa 3 : ![[3 5 8 1 4 2]](https://github.com/blulion/freecodecamp-resource/blob/master/insertion_sort/3.png?raw=true) + ``` key = 1 //3rd index @@ -57,6 +59,7 @@ Etapa 3 : Passo 4 : ![[1 3 5 8 4 2]](https://github.com/blulion/freecodecamp-resource/blob/master/insertion_sort/4.png?raw=true) + ``` key = 4 //4th index @@ -72,6 +75,7 @@ Passo 4 : Passo 5: ![[1 3 4 5 8 2]](https://github.com/blulion/freecodecamp-resource/blob/master/insertion_sort/5.png?raw=true) + ``` key = 2 //5th index @@ -103,8 +107,8 @@ O algoritmo abaixo é uma versão ligeiramente otimizada para evitar a troca do arr[i+1] = key ``` -Aqui está uma implementação detaied em Javascript: -``` +Aqui está uma implementação detalhada em JavaScript: +```js function insertion_sort(A) { var len = array_length(A); var i = 1; @@ -142,7 +146,7 @@ Uma implementação rápida no Swift é mostrada abaixo: ``` O exemplo de Java é mostrado abaixo: -``` +```java public int[] insertionSort(int[] arr) for (j = 1; j < arr.length; j++) { int key = arr[j] @@ -178,8 +182,11 @@ void insertionSort(int arr[], int n) ### Propriedades: -* Complexidade Espacial: O (1) -* Complexidade do Tempo: O (n), O (n \* n), O (n \* n) para Melhor, Média, Piores Casos respectivamente +* Complexidade Espacial: O(1) +* Complexidade do Tempo: O(n), O(n* n), O(n* n) para Melhor, Média, Piores Casos respectivamente + - Melhor Caso: array já está classificado + - Médio Caso: array é aleatoriamente classificado + - Pior Caso: matriz invertida é ordenada. * Classificação no local: sim * Estável: sim @@ -191,3 +198,4 @@ void insertionSort(int arr[], int n) * [Visualização de ordenação de inserção](https://www.hackerearth.com/practice/algorithms/sorting/insertion-sort/visualize/) * [Ordenação de Inserção - MyCodeSchool](https://www.youtube.com/watch?v=i-SKeOcBwko) * [Ordenação de Inserção - VisuAlgo](https://visualgo.net/en/sorting) +