本文整理汇总了C++中tree::RightTree方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::RightTree方法的具体用法?C++ tree::RightTree怎么用?C++ tree::RightTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::RightTree方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: putinstackChar
void putinstackChar(tree<char>& t, stack<char>& s)
{
if (t.LeftTree().empty() && t.RightTree().empty())
{
s.push(t.RootTree());
}
else if (!t.LeftTree().empty() && !t.RightTree().empty())
{
s.push(t.RootTree());
putinstackChar(t.LeftTree(), s);
putinstackChar(t.RightTree(), s);
}
else if (t.RightTree().empty())
{
s.push(t.RootTree());
putinstackChar(t.LeftTree(), s);
}
else if (t.LeftTree().empty())
{
s.push(t.RootTree());
putinstackChar(t.RightTree(), s);
}
}
示例2: putinstack
void putinstack(tree<int>& t, stack<int>& s, stack<int>& tops)
{
if (t.LeftTree().empty() && t.RightTree().empty())
{
s.push(t.RootTree());
tops.push(1);
}
else if (!t.LeftTree().empty() && !t.RightTree().empty())
{
tops.push(topsCount(t));
s.push(t.RootTree());
putinstack(t.LeftTree(), s, tops);
putinstack(t.RightTree(), s, tops);
}
else if (t.RightTree().empty())
{
tops.push(topsCount(t));
s.push(t.RootTree());
putinstack(t.LeftTree(), s,tops);
}
else if (t.LeftTree().empty())
{
tops.push(topsCount(t));
s.push(t.RootTree());
putinstack(t.RightTree(), s, tops);
}
}
示例3: topsCount
int topsCount(tree<int>& t)
{
if (t.empty()) return 0; // prazno
else if (t.LeftTree().empty() && t.RightTree().empty()) return 1; // listo // nenujno
else if (t.LeftTree().empty()) return 1 + topsCount(t.RightTree()); // ima dqsno // nenujno
else if (t.RightTree().empty()) return 1 + topsCount(t.LeftTree()); // ima lqvo // nenujno
else return 1 + topsCount(t.LeftTree()) + topsCount(t.RightTree()); // ima i lqvo i dqsno
}
示例4: areMirrored
bool areMirrored(tree<int> l, tree<int> r) {
if (l.empty() && r.empty()) {
return true;
}
if (l.empty() || r.empty()) {
return false;
}
if (l.RootTree() != r.RootTree()) {
return false;
}
return areMirrored(l.LeftTree(), r.RightTree())
&& areMirrored(l.RightTree(), r.LeftTree());
}
示例5: treeHeight
int treeHeight(tree<int> t) {
if (t.empty()) {
return 0;
}
int leftTreeHeight = treeHeight(t.LeftTree());
int rightTreeHeight = treeHeight(t.RightTree());
return 1 + max(leftTreeHeight, rightTreeHeight);
}
示例6: isMirrored
bool isMirrored(tree<int> t) {
if (t.empty()) {
return true;
}
return areMirrored(t.LeftTree(), t.RightTree());
}