(Book) library sort/management
Find a file
2025-04-23 19:10:43 -05:00
.gitignore init 2025-04-23 18:08:31 -05:00
books.txt init 2025-04-23 18:08:31 -05:00
CMakeLists.txt Fixed includes for CMake 2025-04-23 18:08:43 -05:00
library.cpp Shuffle implemented 2025-04-23 18:08:43 -05:00
library.h init 2025-04-23 18:08:31 -05:00
main.cpp init 2025-04-23 18:08:31 -05:00
node.h init 2025-04-23 18:08:31 -05:00
README.md added other deliverable as readme 2025-04-23 19:10:43 -05:00

CSE 1384

Lab 9 - Sorting/Searching

  • When it comes to linked lists, linear search is almost always better than binary search. Why?

    • Binary search works best when you have direct access to the data. With linked lists, you cannot access members of the list by an index. This means you have to iterate through the entire list. Linear search is the best option because you had to iterate through it anyways.
  • What sorting algorithm did you use?

    • I used insertion sorting for the Library::reverseSort() function.
  • What was your strategy while building your shuffle? How does your shuffle work?

    • My Library::shuffle() function does the following:

      • Seeds the random generator with the current time using ctime and cstdlib

      • Iterates through the list size, generating a new random integer and cutting it into a single digit

      • Swaps the title and author of each list member with another member at i + n, where i is the index of the current member and n is the randomly generated integer

      This effectively shuffles the list with each member pseudo-randomly swapped with another member.

Sources

Reference : <cstdlib> : srand - cplusplus.com

Binary search - Zybooks 9.3

Insertion sort - Zybooks 9.7

cplusplus.com was used to reference the usage of srand and rand. I adopted the binary search and insertion sort examples from zyBooks to be compatible with the singly-linked list from library.h.