<?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-2006-05-16%3Amgar059</id>
	<title>SE250:Lab-2006-05-16:mgar059 - 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-2006-05-16%3Amgar059"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:Lab-2006-05-16:mgar059&amp;action=history"/>
	<updated>2026-05-19T10:06:14Z</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-2006-05-16:mgar059&amp;diff=324&amp;oldid=prev</id>
		<title>Mark: 1 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:Lab-2006-05-16:mgar059&amp;diff=324&amp;oldid=prev"/>
		<updated>2008-03-08T22:35:29Z</updated>

		<summary type="html">&lt;p&gt;1 revision(s)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:35, 8 March 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en-GB&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key mediawiki-mw_:diff:1.41:old-323:rev-324 --&gt;
&lt;/table&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:Lab-2006-05-16:mgar059&amp;diff=323&amp;oldid=prev</id>
		<title>Mark at 20:53, 23 July 2006</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:Lab-2006-05-16:mgar059&amp;diff=323&amp;oldid=prev"/>
		<updated>2006-07-23T20:53:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Lab 9==&lt;br /&gt;
&lt;br /&gt;
===Red Black Trees===&lt;br /&gt;
&lt;br /&gt;
To rearrange a tree with the initail elements: + A B C D E F G H I J, a simple but slow method is the continue shift the root till each of the branch weights are balanced. Once this is achived, do the same with both branches and continue down till the entire tree is balanced. The process for the first step is as follows.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt; root&lt;br /&gt;
 &amp;gt; &amp;lt;&amp;lt;&lt;br /&gt;
 &amp;gt; root&lt;br /&gt;
 &amp;gt; &amp;lt;&amp;lt;&lt;br /&gt;
 &amp;gt; root&lt;br /&gt;
 &amp;gt; &amp;lt;&amp;lt;&lt;br /&gt;
 &amp;gt; root&lt;br /&gt;
 &amp;gt; &amp;lt;&amp;lt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Slow Method===&lt;br /&gt;
#Keep rotating the root till half of the tree is on each side.&lt;br /&gt;
#Balance each side in the same manner.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Add an element to unbalance the tree:====&lt;br /&gt;
&lt;br /&gt;
For some of these images the red and black nodes are the wrong way around.&lt;br /&gt;
&lt;br /&gt;
[[Image:mgar059250lab1.jpg]]&lt;br /&gt;
&lt;br /&gt;
Add K to make the tree unbalance on the right hand side.&lt;br /&gt;
&lt;br /&gt;
K is a red node and J is also set to red. This means the tree is unbalanced and has to rotate.&lt;br /&gt;
&lt;br /&gt;
I is rotated left&lt;br /&gt;
&lt;br /&gt;
[[Image:mgar059250lab2.jpg]]&lt;br /&gt;
&lt;br /&gt;
I becomes Red and J becomes Black&lt;br /&gt;
&lt;br /&gt;
[[Image:mgar059250lab3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
F is the middle element, so to completely balance the tree, it needs to be shifted around to be the root&lt;br /&gt;
&lt;br /&gt;
[[Image:mgar059250lab4.jpg]]&lt;br /&gt;
&lt;br /&gt;
Remove G so the tree becomes unbalanced.&lt;br /&gt;
&lt;br /&gt;
[[Image:mgar059250lab5.jpg]]&lt;br /&gt;
&lt;br /&gt;
Rotate H left and recolour nodes&lt;br /&gt;
&lt;br /&gt;
[[Image:mgar059250lab6.jpg]]&lt;br /&gt;
&lt;br /&gt;
Is it always possible to re-balance the tree on the path to the root? &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Properly balanced tree&lt;br /&gt;
[[Image:mgar059250lab7.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Questions==&lt;br /&gt;
&lt;br /&gt;
====Question 1====&lt;br /&gt;
Adding an element and deleting it again can change the height of the tree as red black trees are not always compact. Adding an element could cause the tree to be rotate such that the paths shorten and when the element is removed, the tree remains at a shorter height.&lt;br /&gt;
&lt;br /&gt;
====Question 2====&lt;br /&gt;
Adding an element can cause a reduction in the height of the tree as red black trees are not always compact. Adding an element could cause the tree to be rotate such that the paths shorten causing a reduction in height.&lt;br /&gt;
&lt;br /&gt;
====Question 3====&lt;br /&gt;
Deleting an element in the tree cannot increase the size of the tree as the rotations are all designed to reduce height.&lt;br /&gt;
&lt;br /&gt;
====Question 4====&lt;br /&gt;
When adding the sting value &amp;quot;10&amp;quot; the code places it after the 9 instead of between the &amp;quot;1&amp;quot; and &amp;quot;2&amp;quot;. As such there must be code which intreprets stings to be numbers if possible and then treats them as integers.&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>