ORIGINAL AFTER AFTER
CONTENTS DELETE INSERT
TABLE
ENTRY 1
ENTRY 2
ENTRY 3
ENTRY 4
ENTRY
f TO BE
MODIFIED
ENTRY N-1
ENTRY N
I
NEW ENTRY 3
I
Fig. 13-5. Modify table entry actions.
ENTRY N-1
ENTRY N
delete the entry using the delete routine, and then to insert the modi-
fied entry using the insert routine. The actions of the MODIFY are
shown in Fig. 13-5.
The search instructions lend themselves to sequential searches
through tables of data where each data entry is accessed in sequence
while moving through the table forward or backwards. Various other
search algorithms are possible for ordered data entries. A binary
search accesses table entries by comparing the sense of the (key:
table) entry comparison. In a table ordered with entries in ascend-
ing order, the next entry accessed will be the middle entry of the
remaining entries before the current entry, if the current entry is
greater than the key value; or the middle entry of the remaining
entries after the current entry, if the current entry is less than the
key value. The algorithm converges on the sought entry in N = (loge
NENT) + 1, where NENT is the number of entries in the table, as
shown in Fig. 13-6. A table of 1000 entries can be searched for a
ENTRY 1
2
3
4
5
6
7
I
TABEND-1
N-1
TABEND
N
ASCENDING ORDER
Fig. 13 -6. Table for binary
search example.
202
Need help?
Do you have a question about the Z80 and is the answer not in the manual?
Questions and answers