Data Structures from Cormen, Leiserson, Rivest & Stein.
Published byModified over 4 years ago
Presentation on theme: "Data Structures from Cormen, Leiserson, Rivest & Stein."— Presentation transcript:
Data Structures from Cormen, Leiserson, Rivest & Stein
Sets Fundamental to CS Dynamis Sets: manipulated by algorithms, and can grow, shrink, change over time. Operations on sets: –SEARCH(S,k), returns a pointer to k location or NIL –INSERT(S,k) –DELETE(S,k)
Dynamic sets operations (contd) –MINIMUM(S) –MAXIMUM(S) –SUCCESSOR(S,x) –PREDECESSOR(S,x) Most operations return pointers to some location
Stacks and Queues Dynamic sets in which the element removed from the set in the DELETE operation is pre-specified. LIFO – last in first out – in stacks FIFO – first in first out – in queue Stacks - folklore names: PUSH – INSERT POP - DELETE
Stacks We can implement a stack of almost n elements with an array S[1..n]. top[S] – indexes the most recently inserted element. The stack consists of S,…S[top[S]] elements, S is the element at the bottom of the stack, and S[top[S]] is the element at the top of the stack.
Queues ENQUEUE – INSERT to a queue DEQUEUE – Delete from a queue Queues have a head and a tail Inserting at the tail Deleting at the head head[Q] – points to the head tail[Q]-the location to insert a new element