First question ive done a Pointer diagram based on this code.
NEW(NodePtr); NodePtr^.Data := Rec; NodePtr^.Next := DB.Head; DB.Head := NodePtr; DB.Size := DB.Size + 1;
"Draw a pointer diagram, with explanatory text, showing how Add_Record in Book_DB works in the case where there are no records in the database. "
Second question, regarding psudo code?
I've attempted to write psudo code for the following piece of code.
FUNCTION Q_Present(Key : INTEGER; DB : TBookDB; VAR BookRec : TBookRec) : BOOLEAN;
VAR
Pos : INTEGER;
BEGIN
RESULT := FALSE;
Pos := 1;
WHILE (NOT RESULT) AND (Pos <= DB.Size) DO
BEGIN
IF DB.Recs[Pos].Key = Key THEN
BEGIN
RESULT := TRUE;
BookRec := DB.Recs[Pos];
END
ELSE
BEGIN
Pos := Pos + 1;
END
END
END {Q_Present};
{ REQUIRES TRUE}
{ RESULTS RETURNS number of records in DB }
My psudo code
Set result to false.
Set position to 1.
When Result = False and Position less or equal to number of records
Start
Set Result to True
Record = Poistion of record.
Else
Increment Position by 1.
Im new to this forum, an I would be so grateful if anyone of you could help me.
btw this is not assessed its just a excesrise and really want to get a grip of it :irritated:.
Regards
Borny :irritated:


Sign In
Create Account

Back to top









