<?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-7%3Aaomr001</id>
	<title>SE250:lab-7:aomr001 - 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-7%3Aaomr001"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-7:aomr001&amp;action=history"/>
	<updated>2026-06-13T16:06:42Z</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-7:aomr001&amp;diff=7507&amp;oldid=prev</id>
		<title>Mark: 4 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-7:aomr001&amp;diff=7507&amp;oldid=prev"/>
		<updated>2008-11-03T05:20:13Z</updated>

		<summary type="html">&lt;p&gt;4 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== task1 == &lt;br /&gt;
&lt;br /&gt;
for this task we had to populate the tree with the seven elements a-g. &lt;br /&gt;
such that the resulting tree would be perfectly balanced .. &lt;br /&gt;
the order i tried out was [d b f a c e g] .. other orders also work .. such as &lt;br /&gt;
[d f b c a g e] .. as we inserted the median of the values first .. and then inserting either b or f &lt;br /&gt;
first doesn&amp;#039;t really matter as they are the median of the right and left remaining sides. &lt;br /&gt;
same reasoning for inserting a or c first .. or .. e or g first . &lt;br /&gt;
&lt;br /&gt;
(this task was particulary easy and nothing was challenging )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== task2 == &lt;br /&gt;
i entered the elements and then used SKEW command .. &lt;br /&gt;
the order of the tree was ( Tree[a,b,c,d,e,f,g] ) &lt;br /&gt;
&lt;br /&gt;
i then performed a left rotation on the root .. and printed the tree to get&lt;br /&gt;
( Tree[a,b,c,d,e,f,g] ) &lt;br /&gt;
&lt;br /&gt;
which shows that the rotation doesn&amp;#039;t effect the overall order&lt;br /&gt;
of the binary tree.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== task3 ==&lt;br /&gt;
&lt;br /&gt;
i inserted the elements 1-7 in this order &lt;br /&gt;
[1,2,3,4,5,6,7] to get a right skewed data. &lt;br /&gt;
&lt;br /&gt;
we were asked to convert the tree into a left skewed tree&lt;br /&gt;
i did this by performing : &lt;br /&gt;
&amp;lt;pre&amp;gt;left rotation on the root &amp;quot;1&amp;quot;. &lt;br /&gt;
then using root to move to node &amp;quot;2&amp;quot;&lt;br /&gt;
left rotation on the root &amp;quot;2&amp;quot;. &lt;br /&gt;
then using root to move to &amp;quot;3&amp;quot;.&lt;br /&gt;
left rotation on the root &amp;quot;3&amp;quot;.&lt;br /&gt;
then using root to move to node &amp;quot;4&amp;quot;&lt;br /&gt;
left rotation on the root &amp;quot;4&amp;quot;. &lt;br /&gt;
then using root to move to node &amp;quot;5&amp;quot;&lt;br /&gt;
left rotation on the root &amp;quot;5&amp;quot;. &lt;br /&gt;
then using root to move to node &amp;quot;6&amp;quot;&lt;br /&gt;
left rotation on the root &amp;quot;6&amp;quot;. &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== task4 == &lt;br /&gt;
we were asked to balance a right skewed tree &lt;br /&gt;
by performing a number of rotation and movements&lt;br /&gt;
i did this by performing:&lt;br /&gt;
&amp;lt;pre&amp;gt;left rotation on the root &amp;quot;1&amp;quot;. &lt;br /&gt;
then using root to move to node &amp;quot;2&amp;quot;&lt;br /&gt;
left rotation on the root &amp;quot;2&amp;quot;. &lt;br /&gt;
then using root to move to &amp;quot;3&amp;quot;.&lt;br /&gt;
left rotation on the root &amp;quot;3&amp;quot;.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
although this tree is balanced it&amp;#039;s still not a good binary tree because it&amp;#039;s too high.&lt;br /&gt;
to make it more balanced .. most of the branches should have 2 childern .. to minimise the height .. &lt;br /&gt;
therefore minimising the look up time. &lt;br /&gt;
&lt;br /&gt;
== task5 ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Starting with a balanced tree of seven elements, add two new elements&lt;br /&gt;
each larger than the current maximal element and then&lt;br /&gt;
rebalance the tree using a minimal number of rotations.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
i started by adding the elements [ 4,2,6,1,3,5,7]&lt;br /&gt;
then added [8,9] &lt;br /&gt;
&lt;br /&gt;
and then to make the tree balanced .. &lt;br /&gt;
&amp;lt;pre&amp;gt;i moved away from the root using RIGHT twice .. then performed a rotate left .&amp;lt;/pre&amp;gt;&lt;br /&gt;
to make the tree balanced ( the total difference is 1 level therefore it&amp;#039;s a balanced tree )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
http://aamranovich.googlepages.com/test1.jpg&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>