<?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%3Amgha023</id>
	<title>SE250:lab-3:mgha023 - 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%3Amgha023"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-3:mgha023&amp;action=history"/>
	<updated>2026-06-04T17:53:45Z</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:mgha023&amp;diff=5624&amp;oldid=prev</id>
		<title>Mark: 9 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-3:mgha023&amp;diff=5624&amp;oldid=prev"/>
		<updated>2008-11-03T05:19:22Z</updated>

		<summary type="html">&lt;p&gt;9 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;I&amp;#039;m just reading a book call Data Structures Demysitified to get familiar with arrays. I shall begin my lab work only after that. &lt;br /&gt;
&lt;br /&gt;
==1==&lt;br /&gt;
  int main() {&lt;br /&gt;
   &lt;br /&gt;
  	clock_t t0;&lt;br /&gt;
  	int n;&lt;br /&gt;
    	ArrayList xs;&lt;br /&gt;
 	arraylist_init(&amp;amp;xs);&lt;br /&gt;
   &lt;br /&gt;
          t0 = clock(); &lt;br /&gt;
   	for (n=0; n&amp;lt;100000000000; n++){&lt;br /&gt;
 &lt;br /&gt;
  	arraylist_push(&amp;amp;xs, n);&lt;br /&gt;
 	}&lt;br /&gt;
  			  &lt;br /&gt;
 	&lt;br /&gt;
  	printf(&amp;quot;time=%ld\n&amp;quot;, clock() - t0 );&lt;br /&gt;
   &lt;br /&gt;
        return 0;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 When n=1000, time =0&lt;br /&gt;
 n=10000, time=3&lt;br /&gt;
 n=100000,time=16&lt;br /&gt;
 n=1000000,time=160&lt;br /&gt;
 n=10000000,time=1512&lt;br /&gt;
 n=100000000,time=14661&lt;br /&gt;
&lt;br /&gt;
==2==&lt;br /&gt;
&lt;br /&gt;
Changing *2-&lt;br /&gt;
&lt;br /&gt;
 with *4, time for n=1000000 was 183&lt;br /&gt;
 with *25, time for n=1000000 was 175&lt;br /&gt;
 with *40, time for n=1000000 was 150&lt;br /&gt;
 with *100, time for n=1000000 was 213&lt;br /&gt;
 with *1000, time for n=1000000 was 212&lt;br /&gt;
 with *1500, time for n=1000000 was 338&lt;br /&gt;
 with *5000, it took very long to display a time of 20606.&lt;br /&gt;
 *At *6000, it was unable to run it as memory had been exhausted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==3==&lt;br /&gt;
&lt;br /&gt;
Changing initial array sizes-&lt;br /&gt;
&lt;br /&gt;
 When ARRAYLIST_MIN_ALLOC is 16, with n=1000000, time=154 &lt;br /&gt;
 When ARRAYLIST_MIN_ALLOC is 20, with n=1000000, time=171&lt;br /&gt;
 When ARRAYLIST_MIN_ALLOC is 50, with n=1000000, time=166 &lt;br /&gt;
 When ARRAYLIST_MIN_ALLOC is 100, with n=1000000, time=161 &lt;br /&gt;
 When ARRAYLIST_MIN_ALLOC is 500, with n=1000000, time=164 &lt;br /&gt;
 When ARRAYLIST_MIN_ALLOC is 1000, with n=1000000, time=167 &lt;br /&gt;
 When ARRAYLIST_MIN_ALLOC is 1500, with n=1000000, time=162  &lt;br /&gt;
 When ARRAYLIST_MIN_ALLOC is 3000, with n=1000000, time=170&lt;br /&gt;
&lt;br /&gt;
*The times dont seem to change much when the initial array sizes are varied.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==4==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==5==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Changing the growth strategy to an incremental one by changing arraylist_put from *2 to +1000.&lt;br /&gt;
&lt;br /&gt;
 When n&amp;lt;100, t=0&lt;br /&gt;
 n&amp;lt;1000, t=0&lt;br /&gt;
 n&amp;lt;10000, t=3&lt;br /&gt;
 n&amp;lt;100000, t=22&lt;br /&gt;
 n&amp;lt;1000000, t=3051&lt;br /&gt;
 At n&amp;lt;10000000 it took really long and it displayed no answer in the end. &lt;br /&gt;
&lt;br /&gt;
==6==&lt;br /&gt;
&lt;br /&gt;
Using arraylist_put instead of arraylist_push-&lt;br /&gt;
&lt;br /&gt;
 With n&amp;lt;100, t=0&lt;br /&gt;
 With n&amp;lt;1000, t=1&lt;br /&gt;
 With n&amp;lt;10000, t=56&lt;br /&gt;
 With n&amp;lt;100000, t=4597&lt;br /&gt;
 With n&amp;lt;1000000 it took really long and did not display any answer in the end.&lt;br /&gt;
&lt;br /&gt;
From this we can see that adding elements to the front of the array takes longer than adding elements to the end of it.&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>