I’m really puzzled on how to do this… I can’t even figure out how to start, I know how to do it for a binary tree but I want to be able to do it with any form of nested list, can anyone help me out please?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For this one, you need to use the template for traversing an arbitrarily nested list of elements. For example, study this procedure that copies an arbitrarily nested list:
A little convention first. Let’s say that
1is the base level, and that all the elements returned will be in a flat output list (without preserving the original structure of the input list). For example:With the above template in mind, let’s see how we can modify it for solving the problem at hand. I’ll let you fill-in the blanks, because the question looks like homework:
Test the procedure with this list, it must return
'(1)for level1,'(2)for level2, and so on: