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

		<summary type="html">&lt;p&gt;8 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;
After looping through 100 times, the height of the tree seen to increasing less and less while having large variation between a logarithmic graph.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	for (i = 0; i&amp;lt;100; i++){&lt;br /&gt;
		x = makeRandomTree(i);&lt;br /&gt;
		printf(&amp;quot;size = %d height = %d\n&amp;quot;, i, height(x));&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Task 2==&lt;br /&gt;
Sounds easy, basically traverse through to find the right most or left most node to find the minimum or maximum&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Node* minimum( Node* node ) {&lt;br /&gt;
  /* TODO */&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;
  /* TODO */&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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*However after testing the code, it seen wrong... giving me a weird number each time, I&amp;#039;m not sure whether it is the implementation thats wrong, or the tree is showing it wrong. The tree was REALLY and i mean REALLY hard to understand, it doesn&amp;#039;t even look like a tree...&lt;br /&gt;
&lt;br /&gt;
*After few twitching with the code, I realize I wasn&amp;#039;t showing the correct number, and changing &amp;amp;y-&amp;gt;key to y-&amp;gt;key did the trick. (I should relearn pointers... sigh...)&lt;br /&gt;
&lt;br /&gt;
==Task 3==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Node* lookup( int key, Node* node ) {&lt;br /&gt;
  /* TODO */&lt;br /&gt;
	while (node != empty) {&lt;br /&gt;
		if (key &amp;gt; node-&amp;gt;key) {&lt;br /&gt;
			node = node-&amp;gt;right;&lt;br /&gt;
		} else if (key &amp;lt; node-&amp;gt;key) {&lt;br /&gt;
			node = node-&amp;gt;left;&lt;br /&gt;
		} else {&lt;br /&gt;
			return node;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return empty;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*This was easy as well, basiclly just a set of rules and which way to go depending on whether the key is larger or smaller at current node.&lt;br /&gt;
==Task 4==&lt;br /&gt;
*Pre-order, after fiddling around through my notes, it meant traversing tree this way &amp;quot;root-&amp;gt;left-&amp;gt;right&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Task 5==&lt;br /&gt;
==Task 6==&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>