-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture "Organising information: trees", exercise 2 #30
Comments
Note: Bugfix: +++ Algorithm with Test Cases +++
+++ Algorithm with Test Cases and Silvio's Tree +++
|
@essepuntato: that's my take on the exercise. It was very hard to understand how to manipulate properly nodes and I'm not quite sure about it. In the end I've used queues and lists to store "discovered" and "visited" nodes. I'll tweak it later. Also, as mentioned by @SeverinJB, I don't know if I was supposed to print node names or not.
|
Hi all, I'm posting here my take on the exercise - you can find the source of this online as usual. It is worth mentioning that, usually, the breadth visit of a tree is seen as a typical example of iterative algorithm – that's why the solution of this exercise is smaller and more "natural" (at least from my perspective) than the recursive one.
|
I had written this code before, but was still struggling to find a way of producing the desired output without knowing beforehand the number of generations present in the input tree. Now that I have seen Prof. Peroni's take, mine seems a tad convoluted. But I am happy it works, at least with the test case provided by Silvio.
|
Write in Python the pure iterative version of the function defined in the previous exercise.
The text was updated successfully, but these errors were encountered: