HASHING 7/9

 BBS: Inland Empire Archive
Date: 05-09-92 (01:16)             Number: 192
From: TOM HAMMOND                  Refer#: NONE
  To: LYN BORCHERT                  Recvd: NO  
Subj: HASHING     7/9                Conf: (2) Quik_Bas
Continued from Hashing 6/7

          IF Action$ <> "" THEN
             Action$ = WhackIt$(Action$)

             IF Action$ = "C" THEN
            'else if we are to change the number
            INPUT "New phone number please"; PhoneNumber$
            PhoneNumber$ = UCASE$(RTRIM$(LTRIM$(PhoneNumber$)))

            IF PhoneNumber$ = "" THEN
               PRINT "Number not changed"
            ELSE
               a$(Index%, 1) = PhoneNumber$
               PRINT "Phone number has been updated."
            END IF

             ELSEIF Action$ = "D" THEN
            a$(Index%, 0) = DeletedValue$
            PRINT "Entry has been deleted."

             ELSE
            'an invalid entry was made
            PRINT "Please enter a D to Delete the number,"
            PRINT "a C to Change it, or"
            PRINT "just press Enter to continue."
            Action$ = "DUMMY"
             END IF
          END IF
       LOOP

        ELSE
      PRINT TestName$; "'s Phone Number Is Not On File.  You May_
Enter It To Add"
       PRINT "It, Or Just Press "; CHR$(34); "ENTER"; CHR$(34); " To_
Continue.";
       INPUT PhoneNumber$
       PhoneNumber$ = UCASE$(RTRIM$(LTRIM$(PhoneNumber$)))

       IF PhoneNumber$ <> "" THEN
          IF SaveIndex% <> -1 THEN
             'reuse delete space
             Index% = SaveIndex%
             PRINT "We are reclaiming unused space!  Ain't it great!"
             CALL Waiter
          END IF

          a$(Index%, 0) = TestName$
          a$(Index%, 1) = PhoneNumber$
       END IF
        END IF

     END IF
  LOOP

  ExitRoutine:
  SYSTEM

  Analyse:
  'process all the data elements in A$ to see:
  ' how full A$ is,
  ' best and worst case access to A$,
  ' mean, SD of access count

  ' Statistics routines "borrowed" in part from
  ' "Some Common Basic Programs" pg 121-122
  ' by Lon Poole and Mary Borchers
  ' Published by Adam Osborne
  ' Copyright 1977
  ' pages 121-123
  PRINT "Analysis Begins.... Please Wait....."

  Best% = 999
  Worst% = 0
  S = 0 ' we are dealing with a population, not a sample
  N = 0 ' count of active elements
  M = 0 ' Sum of X^2
  p = 0 ' Sum of X

  FOR I% = 0 TO ArraySize%
      IF a$(I%, 0) <> "" AND a$(I%, 0) <> DeletedValue$ THEN
         CALL GetData(a$(I%, 0), Index%, Tries%, FirstDeleted%)
         N = N + 1              ' Bump entry count
         p = p + Tries%         ' Bump sum of X
         M = M + (Tries% ^ 2)   ' Bump sum of X^2

         IF Tries% < Best% THEN
        Best% = Tries%
        BestOne% = Index%
         END IF

         IF Tries% > Worst% THEN
        Worst% = Tries%
        WorstOne% = Index%
         END IF
      END IF
  NEXT I%

Continues in next file (HASHING - 8 of 9)


--- WM v2.00/91-0231
 * Origin: The Modem Zone BBS (314) 893-5106 (1:289/2)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET