Question
The Library Abstract Data Type stores details of published academic papers. Each paper has one or more authors, a year of publication and a title.
The Library Abstract Data Type stores details of published academic papers.
Each paper has one or more authors, a year of publication and a title. Each
author can be an author or joint author of more than one paper.
The Library ADT includes these operations:
- new, which creates a new, empty library
- addPaper, which adds a paper to the library
- removePaper, which removes a given paper identified by its author(s), year
of publication and title, from the library
- generateLibrary, which generates an unordered list of all the papers in
the library
(a) A paper is represented by an ordered list of three items: a non-empty list of
authors, a year and a title, where an author, a year and a title are all
represented as strings, e.g.
[ ['Miller, B', 'Ranum, D.L.'], '2011', 'Problem solving with algorithms']
[ ['Harris, R'], '1995', 'Enigma'].
Write specification of the problem of checking whether a given author is
one of the authors of a given paper by completing the following template.
You may use English and/or formal mathematical notation.
Name: isAnAuthor
Inputs:
Preconditions:
Outputs:
Postconditions:
(b) i Is it possible to implement the Library ADT using a binary search tree
with an author's name as key? Explain your answer.
ii Suggest a data structure (other than a binary search tree) that could be
used to implement the Library ADT. Explain your choice of data
structure.
(c) Assume that isAnAuthor you specified above has been implemented as a
Python function.
The following standalone Python function removes all the papers from
Library myLib for a given author.
def removeAuthor(myLib,author):
theLib = myLib.generateLibrary()
for paper in theLib:
if isAnAuthor(author, paper):
myLib.removePaper(paper)
What is the best case and the worst case Big-O complexity of the
removeAuthor function for a library myLib with n papers? Explain your
answer.
You may assume that the operation generateLibrary() returns a list of n
items for a library with n papers.
Take each execution of isAnAuthor and removePaper as a basic step of
computation and assume that generateLibrary has complexity O(n).
(d) This part is unrelated to the Library ADT.
A bookshop wants to make an app so that customers can browse
information about its books. A book is identified by a unique string called the
ISBN. The customer should enter the ISBN to be shown the following
associated information about the book: the author (or authors, if more than
one), the title, the publisher and the year of publication.
State and justify what data structure(s) you would use to solve this problem.
State explicitly any assumptions you make.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started