aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-07-26 02:17:00 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-07-26 02:54:02 +0100
commit93d3ce89cc96d3b73940ba566ae181abd109560a (patch)
treec74133452cb00b185b6fe6943611a95f7a2cb537
parent6dfd820772b0de4d85912d4770a5bd6b2caaf619 (diff)
downloadcw_tree-93d3ce89cc96d3b73940ba566ae181abd109560a.tar.gz
cw_tree-93d3ce89cc96d3b73940ba566ae181abd109560a.tar.bz2
cw_tree-93d3ce89cc96d3b73940ba566ae181abd109560a.zip
Fix up indenting and empty children in to_string for node
-rw-r--r--src/main.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index da63953..e013202 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -104,7 +104,7 @@ word_t alloc_node(Node n)
void indent_depth(int depth, std::stringstream &ss)
{
for (int i = 0; i < depth; ++i)
- ss << "\t";
+ ss << " ";
}
std::string to_string(Node n, int depth = 1)
@@ -113,13 +113,13 @@ std::string to_string(Node n, int depth = 1)
ss << "(" << to_string(n.value) << "\n";
indent_depth(depth, ss);
if (n.left == -1)
- ss << "()";
+ ss << "NIL";
else
ss << to_string(nodes[n.left], depth + 1);
ss << "\n";
indent_depth(depth, ss);
if (n.right == -1)
- ss << "()";
+ ss << "NIL";
else
ss << to_string(nodes[n.right], depth + 1);
ss << ")";