i***0 发帖数: 8469 | 1 You are given a binary tree:
struct node
{
int n;
//
value of node
struct node *left;
//
left subtree
struct node *right;
//
right subtree
struct node *level;
//
level pointer (node “to the right”)
}
Initially, the level field is set to NULL.
1. Write a function that will link all the nodes at the same level in a
given tree.
void linkSameLevel(struct node *t);
2. Please explain what the running time and memory usage of your function
are for a tree of depth d
containing n nodes.
For instance, if | h***r 发帖数: 726 | 2 BFS should work.
【在 i***0 的大作中提到】 : You are given a binary tree: : struct node : { : int n; : // : value of node : struct node *left; : // : left subtree : struct node *right;
|
|