40 likes | 124 Views
Get(A, i ) A[ i ] if i is defined # if i is not defined Store(A, i ,x) A[ i ] := x Init(A) A[ i ] := # for all i. Store(A,3,5) A[3] := 5. Store(A,2,6) A[2] := 6. Store(A,5,9) A[5] := 9. Store(A,3,8) A[3] := 8. 5 4 3 2 1 0. 9. 5 4 3 2 1 0. 2. 5 4 3
E N D
Get(A,i) A[i] if i is defined # if i is not defined Store(A,i,x) A[i] := x Init(A) A[i] := # for all i
Store(A,3,5) A[3] := 5 Store(A,2,6) A[2] := 6 Store(A,5,9) A[5] := 9 Store(A,3,8) A[3] := 8 5 4 3 2 1 0 9 5 4 3 2 1 0 2 5 4 3 2 1 0 5 / 8 0 TOP 6 1 5 TOP 2 TOP 3 TOP A B C 3 is in the stack C B[3] < TOP C[B[3]] = 3
Get(A,4) ?A[4] 5 4 3 2 1 0 9 5 4 3 2 1 0 2 5 4 3 2 1 0 4 0 8 TOP 6 1 5 2 3 A B C 4 is in the stack C B[4] < TOP B[4] < TOP B[4] < TOP C[B[4]] = 4 C[B[4]] = 4
Init(A) 5 4 3 2 1 0 9 5 4 3 2 1 0 2 5 4 3 2 1 0 0 8 TOP 6 1 5 2 3 A B C