Pular para o conteúdo principal

Questão de TI - Desenvolvimento de Sistemas — Métodos de Ordenação — FGV 2022

TI - Desenvolvimento de SistemasMétodos de Ordenação
Código
fg152417
Banca
FGV
Órgão
TJDFT
Ano
2022
Cargo
AJ ( )
Analise o código Java a seguir.   import java.util.Arrays; class xSort {   void xsort(int array[]) {     int size = array.length;     for (int step = 1; step < size; step++) {       int key = array[step];       int j = step - 1;       while (j >= 0 && key < array[j]) {         array[j + 1] = array[j];         --j;       }       array[j + 1] = key; System.out.println(Arrays.toString(array));  } } public static void main(String args[]) {   int[] data = { 2, 5, 1, 4, 3 };   xSort is = new xSort();   is.xsort(data);  } }   Considere a seguinte saída no terminal após a execução do código Java apresentado:   [2, 5, 1, 4, 3] [1, 2, 5, 4, 3] [1, 2, 4, 5, 3] [1, 2, 3, 4, 5]   O algoritmo de ordenação implementado no código Java apresentado é o:
  1. ABubble Sort;
  2. BSelection Sort;
  3. CInsertion Sort;
  4. DMerge Sort;
  5. EQuick Sort.
Revelar gabarito e comentário

GabaritoC — Insertion Sort;

Link permanente: /questoes/fg152417