Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data Structures Assignment # 2 You are tasked with implementing a simple book search system for a library. The library contains a collection of books,

Data Structures Assignment # 2
You are tasked with implementing a simple book search system for a library. The library contains a collection of books, and users should be able to search for a book by its title. Implement two search algorithms: linear search and binary search.
Task 1: Data Structure
Define a structure or class called Book to represent a book. Each book should have at least the following attributes:
Title (string)
Author (string)
ISBN (string or int)
Task 2: Linear Search
Implement a linear search function that takes an array of Book objects and the title of the book to search for. The function should return the index of the book in the array if found, or -1 if not found.
Task 3: Binary Search
Assume that the array of Book objects is sorted alphabetically by title. Implement a binary search function that takes the sorted array and the title of the book to search for. The function should return the index of the book in the array if found, or -1 if not found.
Task 4: User Interaction
In the function, create an array of Book objects. Allow the user to input the title of a book they want to search for. Use both the linear search and binary search functions to find the book and display the results.
Task 5:
Implement a more sophisticated search system that allows users to search by author or ISBN as well.
Note:
Ensure that the user can input the title of the book.
The binary search assumes that the library is sorted alphabetically by title. Sorting is done before binary search in this example. You can implement a sorting algorithm of your choice, either as a member function of the class Book or as a stand-alone function in the same file that contains the main() function.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions