Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2021-22 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menĂ¹ personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2021-22 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

VIDEOLEZIONI DEL CORSO DI FONDAMENTI DI PROGRAMMAZIONE AA20-21

PROGRAMMING COURSE VIDEOCONFERENCES AY20-21

ex6 exam question about building a binary tree from a set of strings - bug in my code

_
_ginevra_ (620 points)
0 10 15
in Exam exercises by (620 points)
edited by
Hi all. I have written a code for the ex6, I know there is a bug and I know why and where, but I haven't been able to fix it using the same logic (like without using a for loop over each element of string). So if anyone is interested in finding a way and has found it then please share.
115 views

1 Answer

O
Oakandrew (6400 points)
4 27 63
by (6.4k points)

Hey.

First of all, it is prohibited to share an original code(you can loose points). Anyway I executed your program, and as u mentioned before your code returns IndexError. Each node can have 0,1,2 children nodes, at this point u should slice strings inside of "new" in another way.  Also remember your tree must be sorted according to algorithm described in exercise

Good luck