Answered step by step
Verified Expert Solution
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 #
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 : 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 : 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 if not found.
Task : 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 if not found.
Task : 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 :
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 standalone function in the same file that contains the main function.
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