preorder_tree_construction minor changes.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
VIM: let b:lcppflags="-std=c++11 -O2 -pthread"
|
||||||
|
VIM: let b:wcppflags="/O2 /EHsc /DWIN32"
|
||||||
|
VIM: let b:argv=""
|
||||||
|
*/
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -15,7 +20,7 @@ struct node {
|
|||||||
};
|
};
|
||||||
|
|
||||||
node * prefix_to_tree( const std::vector<double>& v ){
|
node * prefix_to_tree( const std::vector<double>& v ){
|
||||||
|
|
||||||
if ( !v.size() ){
|
if ( !v.size() ){
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -53,7 +58,6 @@ node * prefix_to_tree( const std::vector<double>& v ){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << root << std::endl;
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,8 +78,9 @@ void traverse( node * root, std::vector<double>& v ){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void test( const std::vector<double>& v ){
|
void test( const std::vector<double>& v ){
|
||||||
|
std::cout << "-----------------------------------------------------" << std::endl;
|
||||||
auto r = prefix_to_tree( v );
|
auto r = prefix_to_tree( v );
|
||||||
//print( r );
|
print( r );
|
||||||
std::vector<double> w;
|
std::vector<double> w;
|
||||||
traverse( r, w );
|
traverse( r, w );
|
||||||
if ( v.size() != w.size() ) {
|
if ( v.size() != w.size() ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user