This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 2 Time complexity: O ( n 2 ) sum=0; for(i = 0; i < n^2; i++) for(j = 0; j < i; j++) sum++; Time complexity: O ( n 4 ) sum=0; for(i = 0; i < n; i += 2) for(j = 0; j < i; j++) sum++; Time complexity: O ( n 2 ) Implementation notes Implementing a linked list with nested classes (Java). Last time: use a linked list to implement an array • void addElement(Object o, int index) • Object getElement(int index) • Constructor ListArray(int size)...
View Full Document
This note was uploaded on 12/10/2008 for the course CS 20 taught by Professor Agrawal during the Fall '08 term at UCSB.
- Fall '08