227k views
0 votes
.13 LAB: Library book sorting Two sorted lists have been created, one implemented using a linked list (LinkedListLibrary linkedListLibrary) and the other implemented using the built-in Vector class (VectorLibrary vectorLibrary). Each list contains 100 books (title, ISBN number, author), sorted in ascending order by ISBN number. Complete main() by inserting a new book into each list using the respective LinkedListLibrary and VectorLibrary InsertSorted() methods and outputting the number of operations the computer must perform to insert the new book. Each InsertSorted() returns the number of operations the computer performs. Ex: If the input is:

User JordyvD
by
4.7k points

1 Answer

3 votes

Answer:

linkedListOperations = linkedListLibrary.InsertSorted(currNode, linkedListOperations); // this is right

linkedListLibrary.InsertSorted(currNode, linkedListOperations); // half right, it count how much operation but it doesn't store it anywhere in main.

vectorOperations = vectorLibrary.InsertSorted(tempBook, vectorOperations); // this is right

vectorLibrary.InsertSorted(tempBook, vectorOperations); // half right, it count how much operation but it doesn't store it anywhere in main.

cout << "Number of linked list operations: " << linkedListOperations << endl;

cout << "Number of vector operations: " << vectorOperations << endl;

Step-by-step explanation:

The first, you are calling InsertSorted with linkedListLibrary and than you can store the number of operation inside the "linkedListOperations" variable. Then you do the same with vectorLibrary.

User Zach Riggle
by
4.9k points