Tags » Tree

Twisted Pine - Day 3

Another hour today, focusing primarily on the background forest in the lower left. I was going to go in with a rubber shaper and blend it all together, but when I stepped back I decided it didn’t need it. 34 more words

Landscape

non-recursive methods to get the height of tree


//find the height of a tree using non-recursive method
//BFS-like method
//Preorder-like method
#include<iostream>
#include<math.h>
#include<stack>
#include<queue>
using namespace std;

struct Node
{
	int data;
	struct Node *left,*right;
};

int Nil=0;
void CreateTree(struct Node *&tree)
{
	int data;
	scanf("%d",&data);
	if(data==Nil)
	{
		tree=NULL;
		return;
	}
	else
	{
		tree=(Node *)(malloc(sizeof(Node)));
		tree->data=data;
		CreateTree(tree->left);
		CreateTree(tree->right);
	}
}

//with BFS method
int BFSheight(struct Node *tree)
{
	int height=-1;
	if(tree==NULL) return 0;
	queue<Node *> testq;
	struct Node *pcurrent=tree;
	struct Node *tail=tree;
	testq.push(pcurrent);

	while(!testq.empty())
	{
		pcurrent=testq.front();
		if(pcurrent->left) testq.push(pcurrent->left);
		if(pcurrent->right) testq.push(pcurrent->right);
		if(pcurrent==tail) 
		{
			tail=testq.back();
			height=height+1;
		}
		testq.pop();
	}
	return height;
}

struct RNode
{
	struct Node *rtree;
	int Lheight;
};

int PreHeight(struct Node *tree)
{
    //non-recursive... 262 more words
Tree

Berlin Photo Diary 2014 - The Tree

Some of you might remember the picture of the tree I posted six months ago. It’s time to revisit the site.

On the left is the tree and the house inside… 71 more words

Photo

Unique Binary Search Trees leetcode

Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?

For example,
Given n = 3, there are a total of 5 unique BST’s. 52 more words

算法题

Tree Wonders If Anyone Heard It Fall

Middle Of Nowhere, Montana – Doug Fir, a 200-year-old coniferous evergreen, took a tumble last week while enjoying his afternoon of standing in the same spot he’d been in his whole life thus far and swaying in the breeze. 141 more words

Lol