chore(i18n,curriculum): update translations (#43140)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8250367417b2b2512c60
|
||||
title: Create a Queue Class
|
||||
title: Creare una classe Coda
|
||||
challengeType: 1
|
||||
forumTopicId: 301631
|
||||
dashedName: create-a-queue-class
|
||||
@ -8,19 +8,19 @@ dashedName: create-a-queue-class
|
||||
|
||||
# --description--
|
||||
|
||||
Like stacks, queues are a collection of elements. But unlike stacks, queues follow the FIFO (First-In First-Out) principle. Elements added to a queue are pushed to the tail, or the end, of the queue, and only the element at the front of the queue is allowed to be removed.
|
||||
Come gli stack, le code sono una raccolta di elementi. Ma a differenza degli stack, le code seguono il principio FIFO (First-In First-Out). Gli elementi aggiunti ad una coda vengono spinti in fondo, o alla fine, della coda, e solo l'elemento nella parte anteriore della coda può essere rimosso.
|
||||
|
||||
We could use an array to represent a queue, but just like stacks, we want to limit the amount of control we have over our queues.
|
||||
Potremmo usare un array per rappresentare una coda, ma proprio come per gli stack, vogliamo limitare la quantità di controllo che abbiamo sulle nostre code.
|
||||
|
||||
The two main methods of a queue class is the enqueue and the dequeue method. The enqueue method pushes an element to the tail of the queue, and the dequeue method removes and returns the element at the front of the queue. Other useful methods are the front, size, and isEmpty methods.
|
||||
I due metodi principali di una classe coda sono il metodo di accodamento e il metodo di rimozione. Il metodo di accodamento spinge un elemento in fondo alla coda, e il metodo di rimozione rimuove e restituisce l'elemento in testa alla coda. Altri metodi utili sono front, size e isEmpty.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write an `enqueue` method that pushes an element to the tail of the queue, a `dequeue` method that removes and returns the front element, a `front` method that lets us see the front element, a `size` method that shows the length, and an `isEmpty` method to check if the queue is empty.
|
||||
Scrivi un metodo `enqueue` che spinge un elemento in fondo alla coda, un metodo `dequeue` che rimuove e restituisce l'elemento in testa alla coda, un metodo `front` che permette di vedere l'elemento in testa alla coda, un metodo `size` che ne mostra la lunghezza, e un metodo `isEmpty` per controllare se la coda è vuota.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `Queue` class should have a `enqueue` method.
|
||||
La tua classe `Queue` dovrebbe avere un metodo `enqueue`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -31,7 +31,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Queue` class should have a `dequeue` method.
|
||||
La tua classe `Queue` dovrebbe avere un metodo `dequeue`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -42,7 +42,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Queue` class should have a `front` method.
|
||||
La tua classe `Queue` dovrebbe avere un metodo `front`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -53,7 +53,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Queue` class should have a `size` method.
|
||||
La tua classe `Queue` dovrebbe avere un metodo `size`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -64,7 +64,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Queue` class should have an `isEmpty` method.
|
||||
La classe `Queue` dovrebbe avere un metodo `isEmpty`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -75,7 +75,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `dequeue` method should remove and return the front element of the queue
|
||||
Il metodo `dequeue` dovrebbe rimuovere e restituire l'elemento in testa alla coda
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -88,7 +88,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `front` method should return value of the front element of the queue
|
||||
Il metodo `front` dovrebbe restituire il valore dell'elemento in testa alla coda
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -101,7 +101,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `size` method should return the length of the queue
|
||||
Il metodo `size` dovrebbe restituire la lunghezza della coda
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -113,7 +113,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `isEmpty` method should return `false` if there are elements in the queue
|
||||
Il metodo `isEmpty` dovrebbe restituire `false` se ci sono elementi nella coda
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 8d1323c8c441eddfaeb5bdef
|
||||
title: Create a Set Class
|
||||
title: Creare una classe Set
|
||||
challengeType: 1
|
||||
forumTopicId: 301632
|
||||
dashedName: create-a-set-class
|
||||
@ -8,7 +8,7 @@ dashedName: create-a-set-class
|
||||
|
||||
# --description--
|
||||
|
||||
In this exercise we are going to create a class named `Set` to emulate an abstract data structure called "set". A set is like an array, but it cannot contain duplicate values. The typical use for a set is to simply check for the presence of an item. We can see how the ES6 `Set` object works in the example below:
|
||||
In questo esercizio creeremo una classe chiamata `Set` per emulare una struttura dati astratta chiamata "set" (insieme). Un set è come un array, ma non può contenere valori duplicati. L'uso tipico di un set è quello di controllare semplicemente la presenza di un oggetto. Possiamo vedere come funziona l'oggetto ES6 `Set` nell'esempio qui sotto:
|
||||
|
||||
```js
|
||||
const set1 = new Set([1, 2, 3, 5, 5, 2, 0]);
|
||||
@ -20,17 +20,17 @@ console.log(set1.has(6));
|
||||
// output: false
|
||||
```
|
||||
|
||||
First, we will create an add method that adds a value to our set collection as long as the value does not already exist in the set. Then we will create a remove method that removes a value from the set collection if it already exists. And finally, we will create a size method that returns the number of elements inside the set collection.
|
||||
In primo luogo, creeremo un metodo di aggiunta che aggiunge un valore alla nostra collezione purché il valore non esista già nel set. Quindi creeremo un metodo di rimozione che rimuove un valore dalla collezione se esiste già. E infine, creeremo un metodo size che restituisce il numero di elementi all'interno della collezione set.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create an `add` method that adds a unique value to the set collection and returns `true` if the value was successfully added and `false` otherwise.
|
||||
Crea un metodo `add` che aggiunge un valore univoco alla collezione impostata e restituisce `true` se il valore è stato aggiunto con successo e `false` altrimenti.
|
||||
|
||||
Create a `remove` method that accepts a value and checks if it exists in the set. If it does, then this method should remove it from the set collection, and return `true`. Otherwise, it should return `false`. Create a `size` method that returns the size of the set collection.
|
||||
Crea un metodo `remove` che accetta un valore e controlla se esiste nel set. Se sì, questo metodo dovrebbe rimuoverlo dalla collezione, e restituire `true`. In caso contrario dovrebber restituire `false`. Crea un metodo `size` che restituisce la dimensione del set.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `Set` class should have an `add` method.
|
||||
La tua classe `Set` dovrebbe avere un metodo `add`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -41,7 +41,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `add` method should not add duplicate values.
|
||||
Il tuo metodo `add` non dovrebbe aggiungere valori duplicati.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -56,7 +56,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `add` method should return `true` when a value has been successfully added.
|
||||
Il tuo metodo `add` dovrebbe restituire `true` quando un valore è stato aggiunto con successo.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -68,7 +68,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `add` method should return `false` when a duplicate value is added.
|
||||
Il tuo metodo `add` dovrebbe restituire `false` quando viene aggiunto un valore duplicato.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -81,7 +81,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Set` class should have a `remove` method.
|
||||
La tua classe `Set` dovrebbe avere un metodo `remove`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -92,7 +92,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `remove` method should only remove items that are present in the set.
|
||||
Il tuo metodo `remove` dovrebbe rimuovere solo gli elementi presenti nel set.
|
||||
|
||||
```js
|
||||
assert.deepEqual(
|
||||
@ -107,7 +107,7 @@ assert.deepEqual(
|
||||
);
|
||||
```
|
||||
|
||||
Your `remove` method should remove the given item from the set.
|
||||
Il tuo metodo `remove` dovrebbe rimuovere dal set l'elemento dato.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -122,7 +122,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Set` class should have a `size` method.
|
||||
La tua classe `Set` dovrebbe avere un metodo `size`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -133,7 +133,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `size` method should return the number of elements in the collection.
|
||||
Il metodo `size` dovrebbe restituire il numero di elementi nella collezione.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8258367417b2b2512c80
|
||||
title: Delete a Leaf Node in a Binary Search Tree
|
||||
title: Eliminare un nodo foglia in un albero binario di ricerca
|
||||
challengeType: 1
|
||||
forumTopicId: 301637
|
||||
dashedName: delete-a-leaf-node-in-a-binary-search-tree
|
||||
@ -8,15 +8,15 @@ dashedName: delete-a-leaf-node-in-a-binary-search-tree
|
||||
|
||||
# --description--
|
||||
|
||||
This is the first of three challenges where we will implement a more difficult operation in binary search trees: deletion. Deletion is difficult because removing nodes breaks links in the tree. These links must be carefully reestablished to ensure the binary tree structure is maintained. For some deletions, this means the tree must be rearranged. In general, you will encounter one of three cases when trying to delete a node: Leaf Node: The target to delete has zero children. One Child: The target to delete only has one child. Two Children: The target to delete has two child nodes. Removing a leaf node is easy, we simply remove it. Deleting a node with one child is also relatively easy, we simply remove it and link its parent to child of the node we deleted. Removing a node with two children is more difficult, however, because this creates two child nodes that need to be reconnected to the parent tree. We'll see how to deal with this case in the third challenge. Additionally, you need to be mindful of some edge cases when handling deletion. What if the tree is empty? What if the node to delete is the root node? What if there are only two elements in the tree? For now, let's handle the first case where we delete a leaf node.
|
||||
Questa è la prima di tre sfide in cui implementeremo un'operazione più difficile negli alberi di ricerca binari: la cancellazione. La cancellazione è difficile perché la rimozione dei nodi rompe i collegamenti nell'albero. Questi collegamenti devono essere ristabiliti attentamente per garantire che la struttura binaria dell'albero sia mantenuta. Per alcune cancellazioni, questo significa che l'albero deve essere riorganizzato. In generale, incontrerai uno di questi tre casi tentando di eliminare un nodo: Nodo foglia: l'obiettivo da eliminare ha zero figli. Un figlio: l'obiettivo da eliminare ha solo un figlio. Due figli: l'obiettivo da eliminare ha due nodi figli. Rimuovere un nodo foglia è facile, semplicemente lo rimuoviamo. Anche l'eliminazione di un nodo con un figlio è relativamente semplice: lo rimuoviamo e colleghiamo il suo genitore al figlio del nodo che abbiamo eliminato. La rimozione di un nodo con due figli è tuttavia più difficile, perché questo crea due nodi figli che devono essere riconnessi all'albero genitore. Vedremo come affrontare questo caso nella terza sfida. Inoltre, bisogna essere consapevoli di alcuni casi base quando si gestisce la cancellazione. Cosa succede se l'albero è vuoto? Cosa succede se il nodo da eliminare è il nodo radice? E se ci fossero solo due elementi nell'albero? Per ora, gestiamo il primo caso in cui cancelliamo un nodo foglia.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create a method on our binary tree called `remove`. We'll build the logic for our deletion operation in here. First, you'll want to create a function within remove that finds the node we are trying to delete in the current tree. If the node is not present in the tree, `remove` should return `null`. Now, if the target node is a leaf node with no children, then the parent reference to it should be set to `null`. This effectively deletes the node from the tree. To do this, you will have to keep track of the parent of the node we are trying to delete as well. It will also be useful to create a way to track the number of children the target node has, as this will determine which case our deletion falls under. We will handle the second and third cases in the next challenges. Good luck!
|
||||
Crea un metodo sul nostro albero binario denominandolo `remove`. Costruiremo qui la logica per la nostra operazione di eliminazione. In primo luogo, vorrai creare una funzione all'interno di remove che trova il nodo che stiamo cercando di eliminare nell'albero corrente. Se il nodo non è presente nell'albero, `remove` dovrà restituire `null`. Ora, se il nodo di destinazione è un nodo dfoglia senza figli, allora il riferimento del genitore ad esso dovrebbe essere impostato a `null`. Questo elimina efficacemente il nodo dall'albero. Per fare questo, dovrai tenere traccia del genitore del nodo che stiamo cercando di eliminare. Sarà anche utile creare un modo per tenere traccia del numero di figli che ha il nodo di destinazione, in quanto ciò determinerà in quale caso rientra la nostra eliminazione. Nelle prossime sfide affronteremo il secondo e il terzo caso. Buona fortuna!
|
||||
|
||||
# --hints--
|
||||
|
||||
The `BinarySearchTree` data structure should exist.
|
||||
La struttura dati `BinarySearchTree` dovrebbe esistere.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -30,7 +30,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The binary search tree should have a method called `remove`.
|
||||
L'albero binario di ricerca dovrebbe avere un metodo chiamato `remove`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -46,7 +46,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Trying to remove an element that does not exist should return `null`.
|
||||
Tentare di rimuovere un elemento che non esiste dovrebbe restituire `null`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -65,7 +65,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
If the root node has no children, deleting it should set the root to `null`.
|
||||
Se il nodo radice non ha figli, l'eliminazione dovrebbe impostare la radice a `null`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -86,7 +86,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `remove` method should remove leaf nodes from the tree.
|
||||
Il metodo `remove` dovrebbe rimuovere i nodi foglia dall'albero.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8258367417b2b2512c81
|
||||
title: Delete a Node with One Child in a Binary Search Tree
|
||||
title: Eliminare un nodo con un figlio in un albero binario di ricerca
|
||||
challengeType: 1
|
||||
forumTopicId: 301638
|
||||
dashedName: delete-a-node-with-one-child-in-a-binary-search-tree
|
||||
@ -8,15 +8,15 @@ dashedName: delete-a-node-with-one-child-in-a-binary-search-tree
|
||||
|
||||
# --description--
|
||||
|
||||
Now that we can delete leaf nodes let's move on to the second case: deleting a node with one child. For this case, say we have a tree with the following nodes 1 — 2 — 3 where 1 is the root. To delete 2, we simply need to make the right reference in 1 point to 3. More generally to delete a node with only one child, we make that node's parent reference the next node in the tree.
|
||||
Ora che sappiamo eliminare i nodi foglia, passiamo al secondo caso: eliminare un nodo con un figlio. Per questo caso, supponiamo di avere un albero con i seguenti nodi 1 — 2 — 3 dove 1 è la radice. Per eliminare il 2, dobbiamo semplicemente far puntare il riferimento destro in 1 a 3. Più in generale per eliminare un nodo con un solo figlio, facciamo in modo che il genitore di quel nodo faccia riferimento al nodo successivo nell'albero.
|
||||
|
||||
# --instructions--
|
||||
|
||||
We've provided some code in our `remove` method that accomplishes the tasks from the last challenge. We find the target to delete and its parent and define the number of children the target node has. Let's add the next case here for target nodes with only one child. Here, we'll have to determine if the single child is a left or right branch in the tree and then set the correct reference in the parent to point to this node. In addition, let's account for the case where the target is the root node (this means the parent node will be `null`). Feel free to replace all the starter code with your own as long as it passes the tests.
|
||||
Abbiamo messo nel nostro metodo `remove` del codice che esegue le attività dall'ultima sfida. Troviamo l'obiettivo da eliminare e il suo genitore e determiniamo il numero di figli che ha il nodo di destinazione. Aggiungiamo qui il caso successivo per i nodi con un solo figlio. Qui dovremo determinare se il singolo figlio è un ramo sinistro o destro nell'albero e quindi impostare il riferimento corretto nel genitore in modo che punti a questo nodo. Inoltre, teniamo conto del caso in cui l'obiettivo è il nodo radice (questo significa che il nodo padre sarà `null`). Sentiti libero di sostituire tutto il codice iniziale con il tuo purché superi i test.
|
||||
|
||||
# --hints--
|
||||
|
||||
The `BinarySearchTree` data structure should exist.
|
||||
La struttura dati `BinarySearchTree` dovrebbe esistere.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -30,7 +30,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The binary search tree should have a method called `remove`.
|
||||
L'albero binario di ricerca dovrebbe avere un metodo chiamato `remove`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -46,7 +46,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Trying to remove an element that does not exist should return `null`.
|
||||
Tentare di rimuovere un elemento che non esiste dovrebbe restituire `null`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -65,7 +65,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
If the root node has no children, deleting it should set the root to `null`.
|
||||
Se il nodo radice non ha figli, l'eliminazione dovrebbe impostare la radice a `null`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -86,7 +86,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `remove` method should remove leaf nodes from the tree.
|
||||
Il metodo `remove` dovrebbe rimuovere i nodi foglia dall'albero.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -114,7 +114,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `remove` method should remove nodes with one child.
|
||||
Il metodo `remove` dovrebbe rimuovere i nodi con un figlio.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -140,7 +140,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Removing the root in a tree with two nodes should set the second to be the root.
|
||||
Rimuovere la radice in un albero con due nodi dovrebbe impostare il secondo come radice.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
Reference in New Issue
Block a user