Data structures

EasyMedium
1234567891011121314151617181920212223
Question 8
Easy

A program uses a record structure of type Book to store details about library books. Inspect the pseudo-code below:

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

book1 ← Book('1984', 'George Orwell', 328, False)
book2 ← Book('The Hobbit', 'J.R.R. Tolkien', 310, False)
book3 ← Book('Dracula', 'Bram Stoker', 418, False)
bookCollection ← [book1, book2, book3]
pages ← 0
position ← 0

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

OUTPUT bookCollection[position].title, ' is the longest book'

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

[1]

Data structures Questions

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