protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it // Button button = FindViewById<Button> (Resource.Id.myButton); // button.Click += delegate { // button.Text = string.Format ("{0} clicks!", count++); }; Stopwatch watch = new Stopwatch(); watch.start(); int maxDepth = Math.Max(minDepth + 2, steps); int stretchDepth = maxDepth + 1; int check = (TreeNode.bottomUpTree(0, stretchDepth)).itemCheck(); Console.WriteLine("stretch tree of depth {0}\t check: {1}", stretchDepth, check); TreeNode longLivedTree = TreeNode.bottomUpTree(0, maxDepth); for (int depth = minDepth; depth <= maxDepth; depth += 2) { int iterations = 1 << (maxDepth - depth + minDepth); check = 0; for (int i = 1; i <= iterations; i++) { check += (TreeNode.bottomUpTree(i, depth)).itemCheck(); check += (TreeNode.bottomUpTree(-i, depth)).itemCheck(); } Console.WriteLine("{0}\t trees of depth {1}\t check: {2}", iterations * 2, depth, check); } Console.WriteLine("long lived tree of depth {0}\t check: {1}", maxDepth, longLivedTree.itemCheck()); watch.stop(); Console.WriteLine("Seconds to compute: " + watch.read() + ""); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it // Button button = FindViewById<Button> (Resource.Id.myButton); // button.Click += delegate { // button.Text = string.Format ("{0} clicks!", count++); }; Stopwatch watch = new Stopwatch(); watch.start(); int maxDepth = Math.Max(minDepth + 2, steps); int stretchDepth = maxDepth + 1; int check = (TreeNode.bottomUpTree(0,stretchDepth)).itemCheck(); Console.WriteLine("stretch tree of depth {0}\t check: {1}", stretchDepth, check); TreeNode longLivedTree = TreeNode.bottomUpTree(0,maxDepth); for (int depth=minDepth; depth<=maxDepth; depth+=2){ int iterations = 1 << (maxDepth - depth + minDepth); check = 0; for (int i=1; i<=iterations; i++) { check += (TreeNode.bottomUpTree(i,depth)).itemCheck(); check += (TreeNode.bottomUpTree(-i,depth)).itemCheck(); } Console.WriteLine("{0}\t trees of depth {1}\t check: {2}", iterations*2, depth, check); } Console.WriteLine("long lived tree of depth {0}\t check: {1}", maxDepth, longLivedTree.itemCheck()); watch.stop(); Console.WriteLine("Seconds to compute: " + watch.read() + ""); }