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!
Seja list uma lista vazia, na qual é realizada a seguinte sequência de operações:
list.addLast(5); list.addFirst(10); list.add(0,15); list.add(3,3); remove(1); list.add(2,8)
Qual a sequência que representa a lista resultante?
------
Let list be an empty list. Consider the following sequence of operations on list:
list.addLast(5); list.addFirst(10); list.add(0,15); list.add(3,3); remove(1); list.add(2,8)
What sequence represents the final configuration of list?
Seja list uma lista ordenada vazia. Esta lista é de valores inteiros e está ordenada de forma crescente. Se for realizada a seguinte sequência de operações:
list.add(5); list.add(10); list.add(3); list.add(15); remove(8); list.add(8)
Qual a sequência que representa a lista ordenada resultante?
-----
Let list be an empty sorted list. The list is of integer values and it is sorted in ascending order. Consider the following sequence of operation on list:list.add(5); list.add(10); list.add(3); list.add(15); remove(8); list.add(8)What sequence represents the final configuration of list?
Uma lista permite inserir um elemento em qualquer posição, independemente do número de elementos.
//
A list allows inserting an element at any position, regardless of the number of elements.Qual é a complexidade temporal do método algoritmoZ, se vec está totalmente preenchido e tem k elementos? // What is the time complexity of the method algorithmZ, if the array vec is full and has k elements?
public int algoritmoZ(int[] vec, int n) { int comp = vec.length-1; return algoritmoZAux(vec, 0, comp, n); } private int algoritmoZAux(int[] vec, int low, int high, int n){ int mid = 0; if (high > low) { mid = (low+high)/2; return Math.max(algoritmoZAux(vec, low, mid, n), algoritmoZAux(vec, mid+1, high, n)); } if (low>high) return 0; else //(low == high) if (vec[high] > n) return 1; else return 0; }
O primeiro elemento inserido numa pilha é sempre o primeiro a ser removido.
//
The first element inserted into a stack is always the first to be removed.Numa lista, a ordem dos elementos depende exclusivamente da ordem de inserção ((o último elemento registado encontra-se no final da lista).
//
In a list, the order of elements depends exclusively on the order of insertion (the last recorded element is at the end of the list).
Seja 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.pop(); p.push(5); p.top(); p.push(2); p.pop();p.top()
Qual a resposta à sétima 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.pop(); p.push(5); p.top(); p.push(2); p.pop();p.top()What is the answer to the seventh operation?
Seja list uma lista ordenada vazia. Esta lista é de valores inteiros e está ordenada de forma crescente. Se for realizada a seguinte sequência de operações:
list.add(5); list.add(10); list.add(3); list.add(15); remove(1); list.add(8)
Qual a sequência que representa a lista ordenada resultante?
-----
Let list be an empty sorted list. The list is of integer values and it is sorted in ascending order. Consider the following sequence of operation on list:list.add(5); list.add(10); list.add(3); list.add(15); remove(1); list.add(8))What sequence represents the final configuration of list?
Seja list uma lista vazia, na qual é realizada a seguinte sequência de operações:
list.addLast(10); list.addFirst(5); list.add(0,3); list.add(3,15); remove(1); list.add(2,8)
Qual a sequência que representa a lista resultante?
-----
Let list be an empty list. Consider the following sequence of operations on list:
list.addLast(10); list.addFirst(5); list.add(0,3); list.add(3,15); remove(1); list.add(2,8)
What sequence represents the final configuration of list?
A complexidade temporal no pior caso do método algoritmoX é O( n ).
//
The worst-case time complexity of the method algoritmoX is O( n ).
public int algoritmoX(int[] vec){ int n = vec.length-1; return algoritmoXAux(vec, 0, n); } private int algoritmoXAux(int[] vec, int low, int high){ if (low>=high) return vec[high]; int mid = (low+high)/2; if (vec[mid] % 2 == 0) return algoritmoXAux(vec, low, mid); else return algoritmoXAux(vec, mid+1, high); }