<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-6%3Adsan039</id>
	<title>SE250:lab-6:dsan039 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-6%3Adsan039"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-6:dsan039&amp;action=history"/>
	<updated>2026-04-29T03:37:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:lab-6:dsan039&amp;diff=7093&amp;oldid=prev</id>
		<title>Mark: 12 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-6:dsan039&amp;diff=7093&amp;oldid=prev"/>
		<updated>2008-11-03T05:20:04Z</updated>

		<summary type="html">&lt;p&gt;12 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;===Task 1:===&lt;br /&gt;
Inserting elements in a random order. – plot height of tree vs. no. of inserted elements.  Determine relationship between height and number of elements.  I completed this task in a less than elegant manner, simply stacking makeRandomTree and printf statements together instead of creating a for loop.  This was simple and seemed to produce similar results to everyone else – the relationship seems to be: height  ~ sqrt(no. of nodes).&lt;br /&gt;
&lt;br /&gt;
===Task 2:===&lt;br /&gt;
  Node* minimum( Node* node ) {&lt;br /&gt;
   while (node-&amp;gt;left != empty) {&lt;br /&gt;
     node = node-&amp;gt;left;&lt;br /&gt;
   }&lt;br /&gt;
   return node;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 Node* maximum( Node* node ) {&lt;br /&gt;
   while (node-&amp;gt;right != empty) {&lt;br /&gt;
     node = node-&amp;gt;right;&lt;br /&gt;
   }&lt;br /&gt;
   return node;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
I think these work, for min value you need to go left and for max value you need to go right.  I stuffed this up a couple of times, first trying to make a new node pointer inside the functions and returning them, and then changing my while loop condition, then changing it back.&lt;br /&gt;
&lt;br /&gt;
===Task 3:===&lt;br /&gt;
This task caught me for a bit, i consulted the 2007 HTTB and gained the understanding required to complete and (hopehully) understand the task.  Here is my code:&lt;br /&gt;
&lt;br /&gt;
 Node* lookup( int key, Node* node ) {&lt;br /&gt;
   if(node == empty) {&lt;br /&gt;
     return empty;&lt;br /&gt;
   }&lt;br /&gt;
   if(key &amp;lt; node-&amp;gt;key) {&lt;br /&gt;
     return lookup(key, node-&amp;gt;left);&lt;br /&gt;
   }&lt;br /&gt;
   else if(key &amp;gt; node-&amp;gt;key) {&lt;br /&gt;
     return lookup(key, node-&amp;gt;right);&lt;br /&gt;
   }&lt;br /&gt;
   else if(key == node-&amp;gt;key) {&lt;br /&gt;
     return node;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
I used this code to see whether or not it works, it seems to run:&lt;br /&gt;
  &lt;br /&gt;
 Node *tree = makeRandomTree(640);&lt;br /&gt;
 Node *max = maximum(tree);&lt;br /&gt;
 Node *value = lookup(max-&amp;gt;key, tree);&lt;br /&gt;
 printf(&amp;quot;%d is max\n%d is looked up&amp;quot;, max-&amp;gt;key, value-&amp;gt;key);&lt;br /&gt;
&lt;br /&gt;
returns:&amp;lt;br&amp;gt;&lt;br /&gt;
2145324179 is max&amp;lt;br&amp;gt;&lt;br /&gt;
2145324179 is looked up&lt;br /&gt;
&lt;br /&gt;
===Task 4/5:===&lt;br /&gt;
These tasks confused me for a while and i did not figure them out before the end of the lab.  i didn&amp;#039;t think the code was too difficult to write, it just required understanding of pre and post ordering.  I read task 6 and the code in the HTTB for inserting nodes into a tree, and it looked reasonably difficult. I understood it as best i could, but did not write any code as having the answer right infront of me kinda made it unfair.&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>