<?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%3Ahlin079</id>
	<title>SE250:lab-7:hlin079 - 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%3Ahlin079"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-7:hlin079&amp;action=history"/>
	<updated>2026-04-29T10:23:44Z</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:hlin079&amp;diff=7601&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-7:hlin079&amp;diff=7601&amp;oldid=prev"/>
		<updated>2008-11-03T05:20:15Z</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;====task1====&lt;br /&gt;
root-&amp;gt; the starting node&lt;br /&gt;
left-&amp;gt;left hand side of the current node&lt;br /&gt;
right-&amp;gt;right hand side of the current node&lt;br /&gt;
parent-&amp;gt;parent node of the current node&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
i toke me a while to figured out how to insert elements&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
====task2====&lt;br /&gt;
the order i used for this task is (d,b, a,c,f,e,g).&lt;br /&gt;
the order of insertion can be start with the right hand side of d (f).&lt;br /&gt;
the order of the insertion of (a&amp;amp;c)and (e&amp;amp;g) do not matter.&lt;br /&gt;
====task3&amp;amp;task 4====&lt;br /&gt;
rl command moved the right of the current node to parent postion.&lt;br /&gt;
rr command moved the left of the current node to parent positon.&lt;br /&gt;
the elements are in the same order before and after rl and rr command.&lt;br /&gt;
skewed and rotated left: &lt;br /&gt;
Before rotation: &lt;br /&gt;
&lt;br /&gt;
 a (*)&lt;br /&gt;
   b&lt;br /&gt;
    c&lt;br /&gt;
      d&lt;br /&gt;
        e&lt;br /&gt;
          f&lt;br /&gt;
            g&lt;br /&gt;
Order Before rotation: Tree[a,b,c,d,e,f,g] &lt;br /&gt;
&lt;br /&gt;
After rotation: &lt;br /&gt;
&lt;br /&gt;
  a&lt;br /&gt;
 b (*)&lt;br /&gt;
   c&lt;br /&gt;
     d&lt;br /&gt;
       e&lt;br /&gt;
         g&lt;br /&gt;
Order after rotation: Tree[a,b,c,d,e,f,g] .&lt;br /&gt;
rl command moved the right of the current node to parent postion.&lt;br /&gt;
rr command moved the left of the current node to parent positon.&lt;br /&gt;
the elements are in the same order before and after rl and rr command.&lt;br /&gt;
&lt;br /&gt;
====task5====&lt;br /&gt;
after right skew the tree, i used &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
move the node to b             use rl&lt;br /&gt;
move the node to a by root     use two rl&lt;br /&gt;
move the node to c by root     use two rl&lt;br /&gt;
move the node to e by root     use rl&lt;br /&gt;
move the node to f by root     use rl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
====task 6====&lt;br /&gt;
changing from right &lt;br /&gt;
 a&lt;br /&gt;
  b&lt;br /&gt;
   c&lt;br /&gt;
    d&lt;br /&gt;
     e &lt;br /&gt;
      f&lt;br /&gt;
       g (*)&lt;br /&gt;
to perfect balance tree&lt;br /&gt;
    a&lt;br /&gt;
   b&lt;br /&gt;
    c &lt;br /&gt;
 d(*)&lt;br /&gt;
    e&lt;br /&gt;
   f&lt;br /&gt;
    g&lt;br /&gt;
This was achieved by &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
move the node to b        use rl&lt;br /&gt;
move the node to a            use two rl&lt;br /&gt;
move the node to the new root c   use a rl then a rr&lt;br /&gt;
move to d by root command          &lt;br /&gt;
move to right -&amp;gt;e         use rl&lt;br /&gt;
move the node to g          use rl&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
Thus, perfect balance was achieved.&lt;br /&gt;
====task7====&lt;br /&gt;
adding 2 elements larger than the largest node into a perfectly balanced tree and using minimum rotations to achieve a perfectly balanced tree &lt;br /&gt;
    a&lt;br /&gt;
   b&lt;br /&gt;
    c&lt;br /&gt;
 d&lt;br /&gt;
    e&lt;br /&gt;
  f&lt;br /&gt;
   g (*)&lt;br /&gt;
     h&lt;br /&gt;
      i&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To balance this tree i moved the node to g and used the rl command to produced this tree: &lt;br /&gt;
&lt;br /&gt;
    a&lt;br /&gt;
   b&lt;br /&gt;
    c&lt;br /&gt;
 d&lt;br /&gt;
    e&lt;br /&gt;
   f&lt;br /&gt;
      g (*)&lt;br /&gt;
     h&lt;br /&gt;
      i&lt;br /&gt;
Is it always possible to rebalance the tree by performing rotations only on nodes along this path?&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>