< previous page page_813 next page >

Page 813
Append (In: list1, list2; Inout: mergedList, index1, index2, index3)
WHILE list1[index1] isn't the sentinel record
  Set mergedList[index3] = list1[index1]
  Increment index1
  Increment index3
WHILE list2[index2] isn't the sentinel record
  Set mergedList[index3] = list2[index2]
  Increment index2
  Increment index3
Set mergedList[index3] = sentinel record

Notice that the Append module doesnot start with an If statement to determine which list is empty, If one of the lists is empty, the While condition for that list ensures that the loop body is skipped. If both lists are empty, both loop bodies are skipped. An If statement is unnecessary and would simply be extra code.
Module Structure Chart:
0813-01.gif
//******************************************************************
// MergeLists program
// This program merges sorted data from three files
// onto a master file with no duplicates.

 
< previous page page_813 next page >