<?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-3%3Allay008</id>
	<title>SE250:lab-3:llay008 - 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-3%3Allay008"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-3:llay008&amp;action=history"/>
	<updated>2026-04-28T14:58:19Z</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-3:llay008&amp;diff=5606&amp;oldid=prev</id>
		<title>Mark: 19 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-3:llay008&amp;diff=5606&amp;oldid=prev"/>
		<updated>2008-11-03T05:19:21Z</updated>

		<summary type="html">&lt;p&gt;19 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;TASK ONE&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The first task was quite straightforward but it took me a while to get going. I read each of the functions and tried to understand what they did.  I used the init_arraylist function to initialise the array and then called the clock function outside a for loop, inside which arraylist_push was called n number of times to insert the number 10 into the array.  t1 was subtracted from t0 and printed at the bottom. &lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;Results&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
 &lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;n&amp;#039;&amp;#039;&amp;#039;              &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 1000000        46&lt;br /&gt;
 10000000       420&lt;br /&gt;
 100000000      4259   *here I first noticed a significant time lag*&lt;br /&gt;
 1000000000     this produced the error:&lt;br /&gt;
                &amp;quot;assertion &amp;quot;alist-&amp;gt;arr != (element_t*)0&amp;quot; failed: file &amp;quot;arraylist.c&amp;quot;, line 39&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The code came up with many errors the first time I compiled it, but these were mainly small mistakes in my code. There was one strange error that I could not get rid of.  I later discovered that this was because I needed to compile &amp;quot;arraylist.c&amp;quot; before I ran my own code.  At the time I corrected this error by pasting my code at the bottom of &amp;quot;arraylist.c&amp;quot;  After I corrected it I still came up with errors.  This was because emacs was running the wrong compiler.  After I had help correcting this my program finally ran error free.&lt;br /&gt;
&lt;br /&gt;
Note for the future: To change compiler: Options/Customize Emacs/Specific Options... Type at the bottom: shell-file-name&lt;br /&gt;
Change Shell File Name to C:/cygwin/bin/bash.exe&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;TASK TWO&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Keeping n as 10000000 (similar to case 2 in the above example)  I changed the &amp;quot;*2&amp;quot; in &amp;quot;arraylist_put&amp;quot;.&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;Results&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 &lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;*n&amp;#039;&amp;#039;&amp;#039;    &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 4     327      &lt;br /&gt;
 8     358&lt;br /&gt;
 16    327&lt;br /&gt;
 32    328&lt;br /&gt;
 64    this produced the error:&lt;br /&gt;
       assertion &amp;quot;alist-&amp;gt;arr != (element_t*)0&amp;quot; failed: file &amp;quot;arraylist.c&amp;quot;, line 39&lt;br /&gt;
       5764 Hangup                  ./arraylist.exe&lt;br /&gt;
&lt;br /&gt;
These results were all around the same value, which was not what I expected. The time taken did not increase with size that the array was increased by.&lt;br /&gt;
&lt;br /&gt;
Next I tried the same experiment, but only using small increments.&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;Results&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 &lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;*n&amp;#039;&amp;#039;&amp;#039;    &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 1.1     952      &lt;br /&gt;
 1.3     562&lt;br /&gt;
 1.5     483&lt;br /&gt;
 1.7     436&lt;br /&gt;
 1.9     390&lt;br /&gt;
 2.0     405&lt;br /&gt;
 2.5     373&lt;br /&gt;
&lt;br /&gt;
There is pattern to the results.  The closer &amp;quot;*n&amp;quot; is to 1 the longer the program takes.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;TASK THREE&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This task is again very straightforward.  &lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;ARRAYLIST_MIN_ALLOC&amp;#039;&amp;#039;&amp;#039;   &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 16             405     *from previous example*&lt;br /&gt;
 2              452&lt;br /&gt;
 8              421&lt;br /&gt;
 32             452&lt;br /&gt;
 100            390&lt;br /&gt;
 10000          373&lt;br /&gt;
 100000000      327&lt;br /&gt;
&lt;br /&gt;
The trend indicated by these results is that the time decreases with the length of the array.  The difference, though, is so small as to be insignificant.  I had to increase ARRAYLIST_MIN_ALLOC by a considerable amount before I got a noticible difference.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;TASK FOUR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
I inserted the function &amp;quot;ensure_capacity&amp;quot; and ran the code, repeating experiment 1&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;Results&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
 &lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;n&amp;#039;&amp;#039;&amp;#039;              &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039;         &amp;#039;&amp;#039;&amp;#039;time from task one&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 1000000        31           46&lt;br /&gt;
 10000000       343          420       &lt;br /&gt;
 100000000      3370         4259      &lt;br /&gt;
 1000000000     error        error&lt;br /&gt;
&lt;br /&gt;
As can be seen by the results, using &amp;quot;ensure_capacity&amp;quot; decreases the compiling time.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;TASK FIVE&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This task involves changing &amp;quot;*n&amp;quot; to an incremental value such as &amp;quot;+ n&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;+ n&amp;#039;&amp;#039;&amp;#039;            &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 10             ?         *this took ages to compile, so I stopped it prematurely*&lt;br /&gt;
 100            46&lt;br /&gt;
 1000           31&lt;br /&gt;
 5000           46&lt;br /&gt;
 10000          30&lt;br /&gt;
 100000         46&lt;br /&gt;
 100000000      46&lt;br /&gt;
&lt;br /&gt;
There is no difference in compile time when you increment n, provided the n is over a particular number (in which case it takes forever to compile).&lt;br /&gt;
&lt;br /&gt;
I realised as I started Task Six that I had left ARRAYLIST_MIN_ALLOC as 1000000000 (or something like it) for Tasks Four and Five.  I changed it back to 16. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;TASK SIX&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This task involced using &amp;quot;ararylist_put&amp;quot; to put elements at the beginning of the array.&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;n&amp;#039;&amp;#039;&amp;#039;              &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039;                 &amp;#039;&amp;#039;&amp;#039;time from task one&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 10000          31                   -&lt;br /&gt;
 100000         4625                 -&lt;br /&gt;
 1000000        *took too long*      46&lt;br /&gt;
 10000000       *took too long*      420       &lt;br /&gt;
 100000000      *did not try*        4259      &lt;br /&gt;
 1000000000     *did not try*        error&lt;br /&gt;
&lt;br /&gt;
As is evidenced by these results, this takes *considerably* longer.  The smallest value of n from the first task, in task six took so long to process that I gave up on it.  This is *not* an effective way of adding data and should be avoided.&lt;br /&gt;
&lt;br /&gt;
Overall, this lab was easy to implement, but some of the results were interesting, particularly those of task six.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Screencast ==&lt;br /&gt;
&lt;br /&gt;
[[user:llay008]]&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>