SE250:lab-3:tsen009
Jump to navigation
Jump to search
Web page under construction... please GO AWAY!!! come again later... hehe...
im serious, go away already....
u sure dont listen do you...
Task
The task was to pretty much mess around with array lists, and how they work and the time they usually take to compile/run.
Tasks
Task 1
simply add the following code to the bottom of the given arraylist.c
int main (){ ArrayList bob; int i=0; arraylist_init(&bob); clock_t start = clock(); for (i= 0; i < 1000000; i++){ arraylist_push(&bob, 1); } clock_t finish = clock(); printf("to add %d elements to the array list took %f seconds\n", i, (double)(finish - start)); return 0; }
and at the top, make sure you have these libraries,
#include <stdio.h> /* for printf */ #include <stdlib.h> /* for malloc, realloc, free */ #include <string.h> /* for memmove */ #include <assert.h> /* for assert */ #include <time.h> /* for the clock */ #include "arraylist.h"
for the computer it was tested, the result lookd something like this,
to add 1000000 elements to the array list took 31.000000 seconds