{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw2sol - Exercise 10.1-1 1 Push(S,4 2 3 4 5 6 2 3 4 5 6 3 4...

This preview shows pages 1–5. Sign up to view the full content.

Exercise 10.1-1 4 Push(S,4) 1 2 3 4 5 6 top[S] = 1 4 1 Push(S,1) 1 2 3 4 5 6 top[S] = 2 4 1 3 Push(S,3) 1 2 3 4 5 6 top[S] = 3 4 1 3 Pop(S) 1 2 3 4 5 6 top[S] = 2 4 1 8 Push(S,8) 1 2 3 4 5 6 top[S] = 3 4 1 8 Pop(S) 1 2 3 4 5 6 top[S] = 2 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Exercise 10.1-3 4 Enqueue(Q,4) 1 2 3 4 5 6 4 1 1 2 3 4 5 6 4 1 3 1 2 3 4 5 6 4 1 3 1 2 3 4 5 6 4 1 3 8 1 2 3 4 5 6 4 1 3 8 1 2 3 4 5 6 Enqueue(Q,1) Enqueue(Q,3) Dequeue(Q) Enqueue(Q,8) Dequeue(Q) Head[Q] = 1 Tail[Q] = 2 Head[Q] = 1 Tail[Q] = 3 Head[Q] = 1 Tail[Q] = 4 Head[Q] = 2 Tail[Q] = 4 Head[Q] = 1 Tail[Q] = 5 Head[Q] = 3 Tail[Q] = 5 2
Problem 10-1 Unsorted, Single Sorted, Single UnsortedDouble SortedDouble Search ( L, k ) O ( n ) O ( n ) O ( n ) O ( n ) Insert ( L, x ) O (1) O ( n ) O (1) O ( n ) Delete ( L, x ) O ( n ) O ( n ) O (1) O (1) Successor ( L, x ) O ( n ) O (1) O ( n ) O (1) Predecessor ( L, x ) O ( n ) O ( n ) O ( n ) O (1) Minimum ( L ) O ( n ) O (1) O ( n ) O (1) Maximum ( L ) O ( n ) O ( n ) O ( n ) O (1) Exercise 11.2-2 0 1 2 3 4 5 6 7 8 10 19 28 20 12 5 12 15 17 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Exercise 11-2-3 An average has should take around 1 + α where α < 1 to perform an operation.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}