<?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%3Agfun006</id>
	<title>SE250:lab-6:gfun006 - 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%3Agfun006"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-6:gfun006&amp;action=history"/>
	<updated>2026-04-28T16:17:01Z</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:gfun006&amp;diff=7104&amp;oldid=prev</id>
		<title>Mark: 10 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-6:gfun006&amp;diff=7104&amp;oldid=prev"/>
		<updated>2008-11-03T05:20:04Z</updated>

		<summary type="html">&lt;p&gt;10 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;
&lt;br /&gt;
 int main(void) {&lt;br /&gt;
 &lt;br /&gt;
 Node *initial;&lt;br /&gt;
 int i = 0;&lt;br /&gt;
 for (i; i &amp;lt; 51; i++) {&lt;br /&gt;
 initial = makeRandomTree(i);&lt;br /&gt;
 &lt;br /&gt;
 printf(&amp;quot;%d\n&amp;quot;, height(initial));&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
I struggled initially to find out how to make a tree, but then I realized that there was the makeRandomTree function! &amp;gt;_&amp;lt; Since we had to plot a graph, I decided to plot up to 50 points to see what the graph would look like. Probably should of plotted more or made it increment by 5 every time...but I had already moved on by the time I realized this. This is what I analyzed from the graph:&lt;br /&gt;
&lt;br /&gt;
- I used a scatter plot graph&lt;br /&gt;
&lt;br /&gt;
- Since it was a random tree, it meant that just because the size increased doesn&amp;#039;t mean the height increases, sometimes it would decrease. This is just due to how the tree is made and where the nodes are inserted I presume.&lt;br /&gt;
&lt;br /&gt;
- There was still however a noticeable upward curve, even though it was a slow increase.&lt;br /&gt;
&lt;br /&gt;
[http://www.geocities.com/braydondunnit/graph.jpg Graph]&lt;br /&gt;
&lt;br /&gt;
==Task 2==&lt;br /&gt;
&lt;br /&gt;
 Node* minimum( Node* node ) {&lt;br /&gt;
 while  (node-&amp;gt;left != empty) { &lt;br /&gt;
 &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;
 }&lt;br /&gt;
 &lt;br /&gt;
 Node* maximum( Node* node ) {&lt;br /&gt;
 while  (node-&amp;gt;right != empty) {&lt;br /&gt;
 &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;
 }&lt;br /&gt;
&lt;br /&gt;
To find the minimum, it must be on the left most side of the tree, and for maximum it must be on the right most side. This is why for minimum I had node = node-&amp;gt;left and for maximum I had node = node-&amp;gt;right. Originally had trouble figuring out whether my huge values were right: e.g.&lt;br /&gt;
&lt;br /&gt;
 The minimum value of the tree is: 2309112&lt;br /&gt;
 The maximum value of the tree is: 2309136&lt;br /&gt;
&lt;br /&gt;
But figured that since its a random tree, it probably wouldn&amp;#039;t be much of a surprise. As long as the maximum is greater than the minimum I was satisfied. For now.&lt;br /&gt;
&lt;br /&gt;
==Task 3==&lt;br /&gt;
Having lots of trouble figuring out how to make a tree so that I know specifically what values there are so I can check whether my function works or not. I&amp;#039;ve written the function so far:&lt;br /&gt;
&lt;br /&gt;
 Node* lookup( int key, Node* node ) {&lt;br /&gt;
 if (node == empty) {&lt;br /&gt;
 	return node;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 while (node != empty) {&lt;br /&gt;
 	if (key == node-&amp;gt;key)&lt;br /&gt;
 		return node;&lt;br /&gt;
 	else if (key &amp;gt; node-&amp;gt;key)&lt;br /&gt;
 		node = node-&amp;gt;right;&lt;br /&gt;
 	else&lt;br /&gt;
 		node = node-&amp;gt;left;&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
But need to test it to make sure it works.&lt;br /&gt;
&lt;br /&gt;
==Task 4==&lt;br /&gt;
I have no idea what&amp;#039;s going on..at this rate I&amp;#039;ve given up, will try to finish later.&lt;br /&gt;
&lt;br /&gt;
 Node* next_pre( Node* node ) {&lt;br /&gt;
   	if (node-&amp;gt;left != empty)&lt;br /&gt;
 		return next_pre(node-&amp;gt;left) &lt;br /&gt;
 &lt;br /&gt;
  	if (node-&amp;gt;right != empty)&lt;br /&gt;
 		return next_pre(node-&amp;gt;right)&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Task 5==&lt;br /&gt;
&lt;br /&gt;
==Task 6==&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>