Question: 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.
 Data Structures Assignment # 2 You are tasked with implementing a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!