getahead - Searching
  Home
  Character
  Reporting
  Searching
  Grouping
  Concurrent
  Variance
  Contact
  (C) Copyright content

New version April 3 to 4 2018 is here.
TABLE SEARCH WHEN IT HAS MANY KEY CONTENT ARE IN RANDOM ORDER
Given table t of key values in any sequence, and key value e as the search data, then search using this method.
Create table as keys and associate elements
Fill many position with key value and data in associate elements as necessary
Number of the position in table which contains the last key value content is p
Set variable m to value of p plus 1
More program code
Do an individual search
init
(Option here or in through is a Pause and continue use of device when access large table)
Set table t indexed by m to key value e
Set variable i to 0
through
(Option here or in init is a Pause and continue use of device when access large table)
Set i to current value of i plus 1
Compare key value e not equal key value at table t indexed by i, if true jump to through
(Option for compare is code for 1 or more of other operator, selecting criteria, range check)
Compare i equal to m, if true jump to high
Process key value at table t indexed by i and any of its associate elements
(Check more positions for same key value e in table t, if true jump to through)
Jump to high
high
All searching of table t positions for key value e is complete
(Option here is set table t indexed by m to 1 or more of hyphen space 0 or underscore character)
(Complete process of any remaining duplicates found with previous and current key value e)
continue
(Option here is back to More program code and next key value e, or Fill many position with new key value and data in associate elements from the start)
More program code
The formal version of this method was assessed in England by D Knuth in 2005 originally for use by system software engineers and the methods are now available to all.
   
Binary search or segmenting search (see note) is not allowed in all nations and is faster for ordered entries in a table. The search method below is a good alternative.
New version 7 April 2018 is here.
TABLE SEARCH WHEN IT HAS ALL KEY CONTENT ARE IN ASCENDING OR INCREASING ORDER
Given a table t of key values in sequence, and key value e as the search data, then search using this method.
Create table as keys and associate elements
Fill many position with key value and data in associate elements as necessary
Arrange key values in increasing order and complete it, when move a key value also move data in associate elements
Number of the position in table which contains the last key value content is p
Set variable m to value of p plus 1
Set table t indexed by m to a value exceeding the highest key value in the table (higher character codes than Z 9 and prevalent symbols near end of their collating sequence)
More program code
Do an individual search
init
(Option here or in through is a Pause and continue use of device when access large table)
Set variable i to 0
through
(Option here or in init is a Pause and continue use of device when access large table)
Set i to current value of i plus 1
Compare keyvalue e greater key value at table t indexed by i, if true jump to through
Compare key value e less than key value at table t indexed by i, if true jump to high
(Option for compare is code for 1 or more of other operator, selecting criteria, range check)
Process key value at table t indexed by i and any of its associate elements
(Check more positions for same key value e in table t, if true jump to through)
Jump to high
high
All searching of table t positions for key value e is complete
(Complete process of any remaining duplicates found with previous and current key value e)
continue
(Option here is back to More program code and next key value e, or Fill many position with new key value and data in associate elements from the start)
More program code
  
Note binary search or segmenting search is a national algorithm and a respected method for searching data held in a tabular form. There are versions available from many sources and they are not all a complete implementation. In some versions when comparing a search key value to a table key value after reaching a pivot point and there is not a match the code calculates the next pivot point and proceeds to it and that is not the correct process. After the compare at the pivot point the code should increment the index variable to read forward the next 1 2 or 3 locations in the table and compare each time attempting to find a match and optionally the code could at first read the 1 location preceding the pivot point. Fortunately the deficiency is often detected through testing of a program when some input data and search key values are not found in a table and it is confirmed that they are present in the table.
   
The time taken to search can improve for table values arranged in order and when allowed this is by comparing a key value e to a key value in table t indexed by i and starting in the table at 1 or 2 higher positions along than when i is value 1. A higher position can be from deriving a fractional part of the value in variable p and is either 2 or 3 tenths or 7 or 4 tenths or when preferred is either 2 or 3 fifths or 1 fifth and then rounding down the result. Tenth is 0.1 and fifth is 0.2 of a value or amount.
Example is to find the position for key value starting J in a table t which has 1 key value entry for every one of a 26 character alphabet in order the first value for i is 9 when allowed to start comparing from a position 4 tenths along the table. In this example search table t indexed by i starting with i is 9 when using a key value e starting J or any higher character of the alphabet.
The start value for an index variable or subscript is formally defined as 1 or 2 below the value that is provided from comparing the first or more characters of the key value as not exceeding the first or more characters of the key value in table t which are in the first position derived for the fractional part along the table. When that first position is within consecutive positions in table t which have the same first or more characters in a key value then the first position in the table with those characters becomes the new lower first position. When this is not practical then a different fractional part is to be derive and the first position is to be no lower than 2 tenths or 1 fifth or no higher than 7 tenths or 3 fifths along the table.
Include the enhancement for this example in the description of the method appearing above by inserting these 2 lines of text after the line starting Set variable i to 0
Compare key value e greater than Q, if true set variable i to 16 and jump to through
Compare key value e greater than I, if true set variable i to 8
   
To ecofriendly persons
Attempt to use this method and it can help to reduce carbon emissions from producing and using your computer systems.
The benefit from less program code and processor load is lower amounts for electricity invoices and a longer service life for the computer components. Mainframe and server installations will benefit the most from the improvements.
 
 

This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free