
Patrick B. answered 05/09/21
Math and computer tutor/teacher
Routine which parses one record read from file
==============================================
tokens = inbuff.split(",");
dataRecord.recNum = Int(tokens[0]);
dataRecord.name = tokens[1];
dataRecord.address = tokens[2];
Routine which Serializes the data record buffer
==============================================
dataRecordBuff = dataRec.recNum + "," + dataRec.name + "," + dataRec.address
Reads data file
=================
ReadFile( filename, database)
{
opens the file
reads # of records from file
for i = 0 to numRecs-1:
read input buffer
database[i] = parse(input buffer)
endforloop
}
closes the file
Write Data File
================
opens the file
for i=0 to numRecs-1
serialize database(i) to record buffer
writes output buffer to file
closes the file
Linear Search
==============
iIndexPos=-1
for i=0 to numRecs-1
if targetRecord = database(i)
iIndexPos=i
break
return iIndexPos
Insert
=========
if newRecord not found
increases array size by 1
inserts new record at end
sort if necessary
increment record count
write to file
else
record already exist
DELETE
=========
if targetRecord found
moves each record over 1 position to left
decrement record count
write to file
else
record not found
Update
=========
if targetRecord found
replaces old record with new record
writes to file