| 
 |   | 

|   | 

find() for example.
    
class Stack<V> {
  void push(V v) { ... }
  V pop() { ... }
  }
| List | Stack | |||
|---|---|---|---|---|
| create | fast | fast | ||
| delete | fast | fast | ||
| add | slow | fast | ||
| remove | slow | fast | ||
| traversal | fast | na | ||
| navigation | slow | na | ||
| dynamic | no | no | 

class Stack<V>
  // should have error checking.
  void push(V v) { 
    s.addBefore(s.head(), v) }
  V pop() { return s.remove(s.head()) }
  private LinkedList<V> s;
| List | Stack | Stack | ||||
|---|---|---|---|---|---|---|
| (Array) | (List) | |||||
| create | fast | fast | fast | |||
| delete | fast | fast | fast | |||
| add | slow | fast | fast | |||
| remove | slow | fast | fast | |||
| traversal | fast | na | na | |||
| navigation | slow | na | na | |||
| dynamic | no | no | yes | 
| 
 
 | 
 | 

| List | Stack | Stack | Stack | |||||
|---|---|---|---|---|---|---|---|---|
| (Array) | (List) | (DArray) | ||||||
| create | fast | fast | fast | fast | ||||
| delete | fast | fast | fast | fast | ||||
| add | slow | fast | fast | fast* | ||||
| remove | slow | fast | fast | fast* | ||||
| traversal | fast | na | na | na | ||||
| navigation | fast | na | na | na | ||||
| dynamic | No | No | Yes | Yes | 
* Most of the time, slow occasionally.
| 
 
 | 
 | 
| int f() int i, j double x // whatever 
 | 
 | 
| 
 
 | 
 | 
a()
  a() calls b()
    b() calls c()
      c() returns
    b() returns
  a() returns
void reverse(T a[], int n, int i)
  if i < n
    T c = a[i]
    reverse(a, n, i + 1)
    a[n - (i + 1)] = c

| This page last modified on 2011 February 9. |