SE250:lab-4:mcar147

From Marks Wiki
Revision as of 05:19, 3 November 2008 by Mark (Sọ̀rọ̀ | contribs) (2 revision(s))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Lab 4

I kept wanting to do recursion for all the functions despite being told it is not the most effecient way

The best bit of code I managed to write was the nice simple finding of the nth element of a linked list

element_t nth(int i, Cons* list) {
	int cellnumber = 1;
	for( ; (list != nil) && (cellnumber < i); list = list->tail ) {
		cellnumber ++;
	}
	return list->head;
}