informatica:sol:laboratorio18:esercitazionib:esercitazione1
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
| Prossima revisione | Revisione precedente | ||
| informatica:sol:laboratorio18:esercitazionib:esercitazione1 [20/02/2018 alle 07:44 (8 anni fa)] – creata Massimo Torquati | informatica:sol:laboratorio18:esercitazionib:esercitazione1 [20/02/2018 alle 08:33 (8 anni fa)] (versione attuale) – Massimo Torquati | ||
|---|---|---|---|
| Linea 9: | Linea 9: | ||
| ===== Esercizio 2 ===== | ===== Esercizio 2 ===== | ||
| + | |||
| + | Scrivere un programma che, dato un array di N elementi interi, costruisca un albero binario di ricerca (cioè per ogni nodo dell' | ||
| + | Implementare le seguenti funzioni: | ||
| + | <code c> | ||
| + | struct node_t *buildTree(long elem, struct node_t *t); // costruisce l' | ||
| + | long getMin(struct node_t *root); | ||
| + | long getMax(struct node_t *root); | ||
| + | void printInOrder(struct node_t *root); // stampa gli elementi in modo ordinato | ||
| + | void deleteTree(struct node_t *root); | ||
| + | </ | ||
| + | |||
| + | Definire il tipo ' | ||
| + | Il main e' il seguente: | ||
| + | <code c> | ||
| + | int main(int argc, char *argv[]) { | ||
| + | struct node_t *root = NULL; | ||
| + | const long array_size = 10; | ||
| + | long array[] = { 12, 32, 18, -1, 0, 18, -5, 54, 28, 15}; | ||
| + | | ||
| + | for(long i=0; i< | ||
| + | root = buildTree(array[i], | ||
| + | |||
| + | printf(" | ||
| + | printf(" | ||
| + | |||
| + | printInOrder(root); | ||
| + | printf(" | ||
| + | |||
| + | deleteTree(root); | ||
| + | return 0; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Esercizio 3 ===== | ||
| Scrivere una funzione ' | Scrivere una funzione ' | ||
| Linea 50: | Linea 84: | ||
| </ | </ | ||
| - | ===== Esercizio 3 ===== | ||
| - | |||
| - | Scrivere un programma che, dato un array di N elementi interi, costruisca un albero binario di ricerca (cioè per ogni nodo dell' | ||
| - | Implementare le seguenti funzioni: | ||
| - | <code c> | ||
| - | struct node_t *buildTree(long elem, struct node_t *t); // costruisce l' | ||
| - | long getMin(struct node_t *root); | ||
| - | long getMax(struct node_t *root); | ||
| - | void printInOrder(struct node_t *root); // stampa gli elementi in modo ordinato | ||
| - | void deleteTree(struct node_t *root); | ||
| - | </ | ||
| - | |||
| - | Definire il tipo ' | ||
| ===== Esercizio 4 ===== | ===== Esercizio 4 ===== | ||
informatica/sol/laboratorio18/esercitazionib/esercitazione1.1519112686.txt.gz · Ultima modifica: 20/02/2018 alle 07:44 (8 anni fa) da Massimo Torquati
