You need to log in or create an account to post to this user's Wall.
peng commented on the post, Printing a Binary Tree in Zig Zag Level-Order 1 year ago
Hmm, weird, the format is wrong again, anyway it looks like this
void printLevel(Node* n, int level, bool order){
if(n){
if(level==1) “print the data here” […]peng commented on the post, Printing a Binary Tree in Zig Zag Level-Order 1 year ago
Format issue in the previous post, here it is
void printLevel(Node* n, int level, bool order){
if(n){
if(level==1) cout<data<left, level-1, order);
printLevel(n->right, level-1, […]peng commented on the post, Printing a Binary Tree in Zig Zag Level-Order 1 year ago
A solution without extra space (the two stacks) is to write a helper function which prints a specific level of tree in a pre-defined order:
if order is true, left to right, else right to left
void […]
peng commented on the post, Largest Binary Search Tree (BST) in a Binary Tree 1 year ago
I use a Dynamic Programming strategy and I think it is very clear.
I define f(n) as the largest number of nodes in a binary search tree rooted EXACTLY at n. Here as usual, this BST doesn’t need to contain all […]
peng commented on the post, Largest Subtree Which is a Binary Search Tree (BST) 1 year ago
The naive approach is obviously not correct, but the idea of using min and max to keep track of the boundary scope of a BST is brilliant.
peng became a registered member 1 year, 1 month ago
