The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
Lecture 7 - elementary data structures All are O(1) time operations. Listen To Part 7-7 if STACK-EMPTY(S) then error ``underflow'' else Queue Implementation return S[top[S] + 1] A circular queue implementation requires pointers to the head and tail elements, and wraps around to reuse array elements. ENQUEUE(Q, x) Q[tail[Q]] x if tail[Q] = length[Q] file:///E|/LEC/LECTUR17/NODE7.HTM (4 of 13) [19/1/2003 1:34:41] then tail[Q] 1 else tail[Q] tail[Q] + 1
Lecture 7 - elementary data structures DEQUEUE(Q) x = Q[head[Q]] if head[Q] = length[Q] return x then head[Q] = 1 A list-based implementation would eliminate the possibility of overflow. All are O(1) time operations. Listen To Part 7-8 else head[Q] = head[Q] + 1 Dynamic Set Operations Perhaps the most important class of data structures maintain a set of items, indexed by keys. There are a variety of implementations of these dictionary operations, each of which yield different time bounds for various operations. ● Search(S,k) - A query that, given a set S and a key value k, returns a pointer x to an element in S such that key[x] = k, or nil if no such element belongs to S. ● Insert(S,x) - A modifying operation that augments the set S with the element x. ● Delete(S,x) - Given a pointer x to an element in the set S, remove x from S. Observe we are given a pointer to an element x, not a key value. ● Min(S), Max(S) - Returns the element of the totally ordered set S which has the smallest (largest) key. file:///E|/LEC/LECTUR17/NODE7.HTM (5 of 13) [19/1/2003 1:34:41]
- Page 855 and 856: Lecture 2 - asymptotic notation Not
- Page 857 and 858: Lecture 2 - asymptotic notation alg
- Page 859 and 860: Lecture 2 - asymptotic notation Sup
- Page 861 and 862: Lecture 2 - asymptotic notation Nex
- Page 863 and 864: Lecture 3 - recurrence relations Is
- Page 865 and 866: Lecture 3 - recurrence relations
- Page 867 and 868: Lecture 3 - recurrence relations Li
- Page 869 and 870: Lecture 3 - recurrence relations Su
- Page 871 and 872: Lecture 3 - recurrence relations A
- Page 873 and 874: Lecture 4 - heapsort Note iteration
- Page 875 and 876: Lecture 4 - heapsort The convex hul
- Page 877 and 878: Lecture 4 - heapsort 1. All leaves
- Page 879 and 880: Lecture 4 - heapsort left = 2i righ
- Page 881 and 882: Lecture 4 - heapsort Since this sum
- Page 883 and 884: Lecture 4 - heapsort Selection sort
- Page 885 and 886: Lecture 4 - heapsort Greedy Algorit
- Page 887 and 888: Lecture 5 - quicksort Partitioning
- Page 889 and 890: Lecture 5 - quicksort Listen To Par
- Page 891 and 892: Lecture 5 - quicksort Listen To Par
- Page 893 and 894: Lecture 5 - quicksort The worst cas
- Page 895 and 896: Lecture 5 - quicksort Mon Jun 2 09:
- Page 897 and 898: Lecture 6 - linear sorting Since 2i
- Page 899 and 900: Lecture 6 - linear sorting With uni
- Page 901 and 902: Lecture 6 - linear sorting Listen T
- Page 903 and 904: Lecture 7 - elementary data structu
- Page 905: Lecture 7 - elementary data structu
- Page 909 and 910: Lecture 7 - elementary data structu
- Page 911 and 912: Lecture 7 - elementary data structu
- Page 913 and 914: Lecture 7 - elementary data structu
- Page 915 and 916: Lecture 7 - elementary data structu
- Page 917 and 918: Lecture 8 - binary trees - Joyce Ki
- Page 919 and 920: Lecture 8 - binary trees TREE-MINIM
- Page 921 and 922: Lecture 8 - binary trees Inorder-Tr
- Page 923 and 924: Lecture 8 - binary trees Listen To
- Page 925 and 926: Lecture 8 - binary trees insert(b)
- Page 927 and 928: Lecture 8 - binary trees Not (1) -
- Page 929 and 930: Lecture 9 - catch up Next: Lecture
- Page 931 and 932: Lecture 10 - tree restructuring 1.
- Page 933 and 934: Lecture 10 - tree restructuring Lis
- Page 935 and 936: Lecture 10 - tree restructuring Not
- Page 937 and 938: Lecture 10 - tree restructuring Cas
- Page 939 and 940: Lecture 11 - backtracking Next: Lec
- Page 941 and 942: Lecture 11 - backtracking Only 63 s
- Page 943 and 944: Lecture 11 - backtracking Recursion
- Page 945 and 946: Lecture 11 - backtracking Specifica
- Page 947 and 948: Lecture 12 - introduction to dynami
- Page 949 and 950: Lecture 12 - introduction to dynami
- Page 951 and 952: Lecture 12 - introduction to dynami
- Page 953 and 954: Lecture 12 - introduction to dynami
- Page 955 and 956: Lecture 12 - introduction to dynami
Lecture 7 - elementary data structures<br />
All are O(1) time operations.<br />
Listen To Part 7-7<br />
if STACK-EMPTY(S)<br />
then error ``underflow''<br />
else<br />
Queue Implementation<br />
return S[top[S] + 1]<br />
A circular queue implementation requires pointers to the head and tail elements, and wraps around to reuse array<br />
elements.<br />
ENQUEUE(Q, x)<br />
Q[tail[Q]] x<br />
if tail[Q] = length[Q]<br />
file:///E|/LEC/LECTUR17/NODE7.HTM (4 of 13) [19/1/2003 1:34:41]<br />
then tail[Q] 1<br />
else tail[Q] tail[Q] + 1