Шукаєте відповіді та рішення тестів для Algoritmos e Estruturas de Dados - LEI 2026-2027? Перегляньте нашу велику колекцію перевірених відповідей для Algoritmos e Estruturas de Dados - LEI 2026-2027 в moodle.fct.unl.pt.
Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!
Qual é a complexidade temporal do método algoritmoX, se vec está totalmente preenchido e tem k elementos? //What is the time complexity of the method algorithmX, if the array vec is full and has k elements?
public int algoritmoX(int[] vec, int n){ int comp = vec.length-1; return algoritmoXAux(vec, 0, comp, n); } private int algoritmoXAux(int[] vec, int low, int high, int n){ if (low>high) return 0; if (low == high) { boolean res = vec[high] == n; if (res) return 1; else return 0; } int mid = (low+high)/2; return Math.min(algoritmoXAux(vec, low, mid, n), algoritmoXAux(vec, mid+1, high, n)); }
Remover um elemento de uma lista ordenada altera necessariamente a ordem dos restantes elementos.
//
Removing an element from an ordered list necessarily changes the order of the remaining elements.O último elemento inserido numa fila é sempre o primeiro a ser removido.
//
The last element inserted into a queue is always the first to be removed.O TAD Stack tem o comportamento
//
The Stack ADT has the behaviorSeja p uma pilha vazia. Após a execução da seguinte sequência de operações
p.push(2); p.push(5); p.pop(); p.push(2); p.top(); p.push(5); p.top(); p.push(2); p.pop();p.top()
Qual a resposta à quinta operação?
-----
Let p be an empty stack. Consider the following sequence of operations on p:p.push(2); p.push(5); p.pop(); p.push(2); p.top(); p.push(5); p.top(); p.push(2); p.pop();p.top()What is the answer to the fifth operation?
Uma lista pode conter elementos repetidos.
//
A list can contain repeated elements.Qual a complexidade temporal no pior caso do método fatorial? //What is the worst-case time complexity of the method fatorial?
public static long fatorial(int n) { if (n < 0) throw new IllegalArgumentException(); if (n == 0 || n == 1) return 1; else return n * fatorial(n - 1); }
Numa lista ordenada, um elemento pode ser inserido em qualquer posição escolhida pelo utilizador.
//
In an ordered list, an element can be inserted at any position chosen by the user.Indique se a seguinte afirmação é verdadeira ou falsa.
Um algoritmo que tem tempo de execução T( n ) = 1000n+ n 2 +10 tem complexidade temporal O ( n2 )
//
Indicate whether the following statement is true or false.
An algorithm that has a running time of T( n ) = 1000n+ n 2 +10 has time complexity O ( n2 )
Qual a complexidade temporal do método allDiff no pior caso? // What is the worst-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; }