Looking for Algoritmos e Estruturas de Dados - LEI 2026-2027 test answers and solutions? Browse our comprehensive collection of verified answers for Algoritmos e Estruturas de Dados - LEI 2026-2027 at moodle.fct.unl.pt.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Qual a complexidade temporal do método allDiff no melhor caso? //What is the best-case time complexity of the method allDiff?
/** * * @param numbers : an array that is filled up to position n-1 * @return true iff all the numbers are different */ public static boolean allDiff(int[] numbers,int n) { int i=0; while (i<n && diff(numbers[i],numbers,i,n)) i++; return i==n; } private static boolean diff(int number, int[] numbers, int pos, int n) { int i=pos+1; while (i<n && number!=numbers[i]) i++; return i==n; }
Considere um algoritmo que tem taxa de execução T( n ) = 10 n2 + 50 n2
Este algoritmo é (escolha todas as opções correctas).
//
Consider an algorithm that has execution rate T( n ) = 10 n2 + 50 n2This algorithm is (choose all options that apply).
Imagine que tem um programa P implementado, que recebe como input n números. Ao experimentar executá-lo com testes aleatorizados, obteve os seguintes tempos de execução:
demorou 1.5 segundos
demorou 6.0 segundos
demorou 24 segundos
Qual será a complexidade temporal mais provável do programa P?
//
Imagine you have an implemented program P, which receives n numbers as input. When you run it with randomized tests, you get the following execution times:With n=300, it took 1.5 secondsWith n=600, it took 6.0 secondsWith n=1200, it took 24 secondsWhat is the most likely time complexity of program P?
Qual situação representa um cenário de melhor caso do método allDiff? //Which situation represents a best-case scenario for the method allDiff?/** * * @param numbers : an array that is filled up to position n-1 * @return true iff all the numbers are different */ public static boolean allDiff(int[] numbers,int n) { int i=0; while (i<n && diff(numbers[i],numbers,i,n)) i++; return i==n; } private static boolean diff(int number, int[] numbers, int pos, int n) { int i=pos+1; while (i<n && number!=numbers[i]) i++; return i==n; }