Trees Library


Problems 2

Problem : There are several ways to traverse a tree, that is, to go through each of the nodes in a tree. You can either start with the root node, then traverse the two subtrees, or traverse the subtrees, then handle the root node, or traverse the left subtree, then go through the root node, then traverse the right subtree. The methods are called pre-order traversal, post-order traversal and infix traversal respectively. Write a function that prints out the data elements in a tree by traversing the tree with an infix traversal.


Problem : Write a recursive function in the canonical tree-recursion form that will print out a valid English word when given the following tree as input. (Hint: Think of the different traversals).

Problem 2


Problem : Describe an algorithm for writing a level-order traversal, where all of the nodes at depth 0 are printed, then depth 1, then depth 2, etc


Take a Study Break

SparkLife

What's your Pretty Little Liars name?

Take this quiz to find out!

SparkLife

Which young actress just got married?

Click to find out!

SparkLife

Cat bearding WINS THE INTERNET

Have you seen this yet?

SparkLife

Scary movies with funny posters

These. Are. Hilarious.

Geek out!

The MindHut

Geeky Actors: Then and Now

Travel back in time!

The MindHut

Villains We Want These Actresses to Play

From super cute to super bad!

The MindHut

10 Movies Better Than Their Books

What do you think?

The MindHut

Summer Movie Open Thread

Leave your thoughts here!

The MindHut

12 Scientific Inaccuracies in Into Darkness

What did Star Trek get wrong?

The Book

Cover image

Read What You Love, Anywhere You Like

Get Our FREE NOOK Reading Apps