-3

セグメント ツリーを構築しようとしていますが、ノード構造が明確ではありません。見つけたコードを誰か説明してください。

struct node{ 
int count;
node *left, *right;

node(int count, node *left, node *right):
    count(count), left(left), right(right) {}//what this part is doing please explain and how it affects the complexity of the segment tree as compared to other initialization method

node* insert(int l, int r, int w);};
4

1 に答える 1

1

あなたが示した部分は、初期化リストを持つコンストラクターです。さらに混乱させるために、メンバー変数と同じ名前をパラメーターに使用しています。混乱が少ないかもしれませんが、まったく同じコードを書くことができます:

node(int cnt, node *lhs, node *rhs)
    : count(cnt), left(lhs), right(rhs)
{}

または:

node(int cnt, node *lhs, node *rhs)
{
    count = cnt;
    left = lhs;
    right = rhs;
}
于 2015-12-20T14:45:52.863 に答える