Questões de Concurso Público IF-ES 2025 para Técnico de Laboratório / Área: Informática
Foram encontradas 2 questões
class TreeNode { constructor(value) { this.value = value; this.children = []; } addChild(child) { this.children.push(child); } } class Tree { constructor(value) { this.root = new TreeNode(value); }
compute(value) { if (!this.root) return null; const queue = [this.root]; while (queue.length > 0) { const current = queue.shift(); if (current.value === value) { return current; } for (const child of current.children) { queue.push(child); } } return null; } }
O método compute do código é conhecido pelo acrônimo em inglês:
sort = (array) => { if (array.length <= 1) { return array; } const pivot = array[array.length - 1]; const left = []; const right = []; for (let i = 0; i < array.length - 1; i++) { if (array[i] < pivot) { left.push(array[i]); } else {
right.push(array[i]); } } return [...sort(left), pivot, ...sort(right)];
}
Considerando n como o tamanho do vetor, assinale a alternativa CORRETA que corresponde à complexidade média de tempo do algoritmo na notação Big-O: