1. What is a subscript? Subscript represents occurrence # of the Table Entry. Subscript can be represented explicitly and implici...
1. What is a subscript?
Subscript represents occurrence # of the Table Entry. Subscript can be represented explicitly and implicitly. Explicitly means thru occurrence # of the table entry; implicitly means thru a data name. That data name should be defined as an independent item in the Working-Storage Section. The most efficient definition of Subscript is Full-Word binary.
2. What is an index?
Index is assigned to specific table thru INDEXED BY clause. Internally is represented by Index register, which is Full-Word binary. Specific index name can be used to reference a field from the table to which that index is assigned to index represents displacement value of the table entry from the beginning of the table.
3. What is the difference between Subscript and Index?
Index represent displacement value of the table entry from the beginning of the table,
subscript - occurrence # of the table entry. To calculate the displacement of the table entry from its beginning when subscript is used takes 16 additional instructions from the system because of that the usage of the index is more efficient.
An index can only be modified using PERFORM, SEARCH & SET.
Need to have index for a table in order to use SEARCH, SEARCH ALL.
4. What are the different ways of an internal table search?
a. Sequential Search statement. (SEARCH)
b. Binary search statement. (SEARCH ALL)
5. What is the difference between SEARCH and SEARCH ALL?
Serial search (SEARCH) examines each table entry starting at the beginning, whereas a binary search (SEARCH ALL) starts looking at the mid-point of the table and works its way toward the argument depending upon if its too high or too low. A serial search can be used for unsorted tables, while a binary search is only useful if the tables are sorted.
SEARCH ALL is more efficient for tables larger than 70 items.
6. What should be the sorting order for SEARCH ALL? -
It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).
7. What is binary search?
Search on a sorted array. Compare the item to be searched with the item at the middle. If it matches, fine else repeat the process with the left half or the right half depending on where the item lies.
8. My program has an array defined to have 10 items. Due to a bug, I find that even if the program access the 11th item in this array, the program does not ABEND. What is wrong with it?
Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.
9. How tdo change the value of an index in a COBOL programs?
A SET statement.
No comments
Post a Comment