JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat  | Threaded  | Tree
Previous Thread  |  Next Thread
Justify the O(n^2) statement in the list implementation | Reply
public void Show(List l) {
for (int i = 0; i < l.size(); i++) {
System.out.println (l.get(i));
}
}

In reference to http://java.sun.com/j2se/1.4.2/docs/api/java/util/RandomAccess.html

Its clear that
for (int i=0, n=list.size(); i < n; i++)
list.get(i);


runs faster than this loop:

for (Iterator i=list.iterator(); i.hasNext(); )
i.next();
Can you justify the above ..........
Subject Author Date
Justify the O(n^2) statement in the list implementation shantanu.gg Mar 14, 2006 at 3:49 PM EST
Re: Justify the O(n^2) statement in the list implementation AdrianKuegel Mar 14, 2006 at 4:27 PM EST
RSS