In-class-exercise.docx - Name Student ID CS206B 2019 SPRING 1 | P a g e Name Student ID Problem 1 Let T be an ordered tree with more than one node 1.1

In-class-exercise.docx - Name Student ID CS206B 2019 SPRING...

This preview shows page 1 - 5 out of 6 pages.

Name: Student ID: CS206B. 2019 SPRING 1 | P a g e
Name: Student ID: Problem 1. Let T be an ordered tree with more than one node. 1.1) Is it possible that the preorder traversal of T visits the nodes in the same order as the postorder traversal of T ? 1.2) If so, give an example of such a tree; otherwise, explain why this cannot occur. 2-1) Is it possible that the preorder traversal of T visits the nodes in the reverse order of the postorder traversal of T ? yes 2-2) If so, give an example of such a tree; otherwise, explain why this cannot occur. For trees that has single node CS206B. 2019 SPRING 2 | P a g e
Name: Student ID: Problem 2. Draw a binary tree T that simultaneously satisfies the following: Each node of T stores a single character. A preorder traversal of T yields EXAMFUN. An inorder traversal of T yields MAFXUEN. CS206B. 2019 SPRING 3 | P a g e
Name: Student ID: Problem 3. Give an efficient algorithm that computes and prints, for every node u of a tree T, the element of u followed by the height of u ’s subtree. Note:

You've reached the end of your free preview.

Want to read all 6 pages?

• Summer '10
• Tree traversal, preorder traversal

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern