Question: Note: In this problem, you'll be writing - but not solving - a recurrence relation over a data structure. When we get to dynamic programming
Note: In this problem, you'll be writing but not solving a recurrence
relation over a data structure. When we get to dynamic programming
in class, we'll see how to solve these types of recurrences.
Consider a rooted binary tree with nodes are labelled as follows. The
root node is labelled with the empty string. Then, any node that is a
left child of a node with name receives the name and any node
that is the right child of that node receives the name
Give a recurrence relation returning the number of s in all labels of
all nodes. For example, the following tree has s
Hint: For a node let be the number of Rs in the tree rooted
at if the naming started at Also, let resp be the left resp right child of v if it exists or NULL otherwise. Finally, let sv be the number of nodes in the subtree rooted at v and assume this value is stored at each node. Now write a recurrence relation for fv Dont forget to include the base case and to test it on some examples.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
