Data structures

EasyMedium
1234567891011121314151617181920212223
Question 20
Easy

Refer to the following algorithm which uses a RECORD data structure to store details about books in a library.

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

theHobbit ← Book('The Hobbit', 'J.R.R. Tolkien', 310, False)
dracula ← Book('Dracula', 'Bram Stoker', 418, False)
dune ← Book('Dune', 'Frank Herbert', 612, False)
librarySuite ← [theHobbit, dracula, dune]
maxPages ← 0
position ← 0

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

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

Write a pseudo-code statement that updates the dracula record to show that the book is currently on loan.

[1]

Data structures Questions

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