Data structures

EasyMedium
1234567891011121314151617181920212223
Question 5
Easy

A school library uses a record structure to represent books in its catalog.

The following pseudo-code defines the Book record type and instantiates three books:

RECORD Book
    title : String
    author : String
    pages : Integer
    onLoan : Boolean
ENDRECORD

robinsonCrusoe ← Book('Robinson Crusoe', 'Daniel Defoe', 320, True)
treasureIsland ← Book('Treasure Island', 'Robert Louis Stevenson', 280, False)
dracula ← Book('Dracula', 'Bram Stoker', 418, False)
libraryCatalog ← [robinsonCrusoe, treasureIsland, dracula]
maxPages ← 0
position ← 0

FOR i ← 0 TO 2
    IF libraryCatalog[i].pages > maxPages THEN
        maxPages ← libraryCatalog[i].pages
        position ← i
    ENDIF
ENDFOR

OUTPUT libraryCatalog[position].title, ' has the most pages.'

Write a single pseudo-code statement that updates the dracula record to record that the book has been borrowed and is now on loan.

[1]

Data structures Questions

  1. GCSE
  2. /Computer Science
  3. /Data structures