Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 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 2023-24 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.

Which data structure to use?

_
_ginevra_ (620 points)
0 11 15
in HW8 required by (620 points)
Hi!

I am currently stuck on how to proceed with my algorithm.  I understand how to solve the problem with pen and paper but I am not sure of how to implement it. I know that I could create an n-ary tree in which each node is a city but I don't really know how to so I would need to learn how to do it. Then I thought of using dictionaries to associate the city with its secret but would that be a good idea? Do you think that creating an n-ary tree is worth it?

Would be really glad if I could receive any feedback. Thank you.
190 views

1 Answer

b
benjamin (2490 points)
1 7 21
by (2.5k points)
My first suggestion is to use a class to rapresent the nodes in your tree. the idea of the dictionary is pretty good. remember that you can store what data structure you want as values and keys in this dictionary.