chore(i18n,curriculum): update translations (#42969)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8252367417b2b2512c67
|
||||
title: Add Elements at a Specific Index in a Linked List
|
||||
title: Aggiungere elementi ad un indice specifico in una lista collegata
|
||||
challengeType: 1
|
||||
forumTopicId: 301619
|
||||
dashedName: add-elements-at-a-specific-index-in-a-linked-list
|
||||
@ -8,15 +8,15 @@ dashedName: add-elements-at-a-specific-index-in-a-linked-list
|
||||
|
||||
# --description--
|
||||
|
||||
Let's create a addAt(index,element) method that adds an element at a given index. Just like how we remove elements at a given index, we need to keep track of the currentIndex as we traverse the linked list. When the currentIndex matches the given index, we would need to reassign the previous node's next property to reference the new added node. And the new node should reference the next node in the currentIndex. Returning to the conga line example, a new person wants to join the line, but he wants to join in the middle. You are in the middle of the line, so you take your hands off of the person ahead of you. The new person walks over and puts his hands on the person you once had hands on, and you now have your hands on the new person.
|
||||
Creiamo un metodo addAt(index,element) che aggiunge un elemento ad un dato indice. Proprio come come quando rimuoviamo gli elementi in un dato indice, dobbiamo tenere traccia del currentIndex mentre attraversiamo la lista collegata. Quando l'indice corrente corrisponde all'indice dato, dovremmo riassegnare la proprietà next del nodo precedente per fare riferimento al nuovo nodo aggiunto. E il nuovo nodo dovrebbe fare riferimento al nodo successivo in currentIndex. Tornando all'esempio della linea conga, una nuova persona vuole unirsi alla linea, ma vuole unirsi nel mezzo. Tu sei in mezzo alla linea, così togli le mani dalla persona che ti sta davanti. La nuova persona si inserisce e mette le mani sulla persona sulla quale prima avevi le tue mani, e tu ora metti le mani sulla nuova persona.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create an `addAt(index,element)` method that adds an element at a given index. Return false if an element could not be added. **Note:** Remember to check if the given index is a negative or is longer than the length of the linked list.
|
||||
Crea un metodo `addAt(index,element)` che aggiunge un elemento ad un dato indice. Restituisce falso se un elemento non può essere aggiunto. **Nota:** Ricordati di controllare se l'indice fornito è negativo o è più lungo della lunghezza dell'elenco.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `addAt` method should reassign `head` to the new node when the given index is 0.
|
||||
Il tuo metodo `addAt` dovrebbe riassegnare `head` al nuovo nodo quando l'indice dato è 0.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -30,7 +30,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `addAt` method should increase the length of the linked list by one for each new node added to the linked list.
|
||||
Il tuo metodo `addAt` dovrebbe aumentare di uno la lunghezza della lista collegata per ogni nuovo nodo aggiunto alla lista.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -44,7 +44,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `addAt` method should return `false` if a node was unable to be added.
|
||||
Il tuo metodo `addAt` dovrebbe restituire `false` se non è stato possibile aggiungere un nodo.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8256367417b2b2512c78
|
||||
title: Adjacency Matrix
|
||||
title: Matrice di adiacenza
|
||||
challengeType: 1
|
||||
forumTopicId: 301621
|
||||
dashedName: adjacency-matrix
|
||||
@ -8,9 +8,9 @@ dashedName: adjacency-matrix
|
||||
|
||||
# --description--
|
||||
|
||||
Another way to represent a graph is to put it in an <dfn>adjacency matrix</dfn>. An <dfn>adjacency matrix</dfn> is a two-dimensional (2D) array where each nested array has the same number of elements as the outer array. In other words, it is a matrix or grid of numbers, where the numbers represent the edges.
|
||||
Un altro modo per rappresentare un grafico è quello di metterlo in una <dfn>matrice di adiacenza</dfn>. Una matrice di <dfn>adiacenza</dfn> è un array bidimensionale (2D) in cui ogni array annidato ha lo stesso numero di elementi dell'array esterno. In altre parole, è una matrice o una griglia di numeri, dove i numeri rappresentano gli archi.
|
||||
|
||||
**Note**: The numbers to the top and left of the matrix are just labels for the nodes. Inside the matrix, ones mean there exists an edge between the vertices (nodes) representing the row and column. Finally, zeros mean there is no edge or relationship.
|
||||
**Nota**: I numeri in alto e a sinistra della matrice sono solo etichette per i nodi. All'interno della matrice, gli uni significano che esiste un arco tra i vertici (nodi) che rappresentano la riga e la colonna. Infine, gli zeri significano che non c'è un arco o relazione.
|
||||
|
||||
<pre>
|
||||
1 2 3
|
||||
@ -20,7 +20,7 @@ Another way to represent a graph is to put it in an <dfn>adjacency matrix</dfn>.
|
||||
3 | 1 0 0
|
||||
</pre>
|
||||
|
||||
Above is a very simple, undirected graph where you have three nodes, where the first node is connected to the second and third node. Below is a JavaScript implementation of the same thing.
|
||||
Quello sopra è un grafico molto semplice e non orientato con tre nodi, dove il primo nodo è collegato al secondo e al terzo nodo. Di seguito è riportata una implementazione JavaScript della stessa cosa.
|
||||
|
||||
```js
|
||||
var adjMat = [
|
||||
@ -30,7 +30,7 @@ var adjMat = [
|
||||
];
|
||||
```
|
||||
|
||||
Unlike an adjacency list, each "row" of the matrix has to have the same number of elements as nodes in the graph. Here we have a three by three matrix, which means we have three nodes in our graph. A directed graph would look similar. Below is a graph where the first node has an edge pointing toward the second node, and then the second node has an edge pointing to the third node.
|
||||
A differenza di una lista di adiacenza, ogni "riga" della matrice deve avere lo stesso numero di elementi dei nodi nel grafico. Qui abbiamo una matrice tre per tre, il che significa che abbiamo tre nodi nel nostro grafico. Un grafico orientato apparirebbe simile. Di seguito è riportato un grafico in cui il primo nodo ha un arco rivolto verso il secondo nodo, e poi il secondo nodo ha un arco che punta al terzo nodo.
|
||||
|
||||
```js
|
||||
var adjMatDirected = [
|
||||
@ -40,15 +40,15 @@ var adjMatDirected = [
|
||||
];
|
||||
```
|
||||
|
||||
Graphs can also have <dfn>weights</dfn> on their edges. So far, we have <dfn>unweighted</dfn> edges where just the presence and lack of edge is binary (`0` or `1`). You can have different weights depending on your application.
|
||||
I grafici possono anche avere <dfn>pesi</dfn> sui loro archi. Finora, abbiamo archi <dfn>non ponderati</dfn> dove la sola presenza e mancanza di archi è binaria (`0` o `1`). Puoi avere pesi diversi a seconda della tua applicazione.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create an adjacency matrix of an undirected graph with five nodes. This matrix should be in a multi-dimensional array. These five nodes have relationships between the first and fourth node, the first and third node, the third and fifth node, and the fourth and fifth node. All edge weights are one.
|
||||
Crea una matrice di adiacenza di un grafico non orientato con cinque nodi. Questa matrice dovrebbe essere in un array multidimensionale. Questi cinque nodi hanno relazioni tra il primo e il quarto nodo, il primo e il terzo nodo, il terzo e il quinto nodo, il quarto e il quinto nodo. Tutti i pesi degli archi sono uno.
|
||||
|
||||
# --hints--
|
||||
|
||||
`undirectedAdjList` should only contain five nodes.
|
||||
`undirectedAdjList` dovrebbe contenere cinque nodi.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -63,25 +63,25 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
There should be an edge between the first and fourth node.
|
||||
Dovrebbe esserci un arco tra il primo e il quarto nodo.
|
||||
|
||||
```js
|
||||
assert(adjMatUndirected[0][3] === 1 && adjMatUndirected[3][0] === 1);
|
||||
```
|
||||
|
||||
There should be an edge between the first and third node.
|
||||
Dovrebbe esserci un arco tra il primo e il terzo nodo.
|
||||
|
||||
```js
|
||||
assert(adjMatUndirected[0][2] === 1 && adjMatUndirected[2][0] === 1);
|
||||
```
|
||||
|
||||
There should be an edge between the third and fifth node.
|
||||
Dovrebbe esserci un bordo tra il terzo e il quinto nodo.
|
||||
|
||||
```js
|
||||
assert(adjMatUndirected[2][4] === 1 && adjMatUndirected[4][2] === 1);
|
||||
```
|
||||
|
||||
There should be an edge between the fourth and fifth node.
|
||||
Dovrebbe esserci un arco tra il quarto e il quinto nodo.
|
||||
|
||||
```js
|
||||
assert(adjMatUndirected[3][4] === 1 && adjMatUndirected[4][3] === 1);
|
||||
|
Reference in New Issue
Block a user