Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 2: Singly-linked Lists Submit Assignment File Types cpp Due Wednesday by 11:59pm Points 10 Submitting a file upload Available Feb 8 at 12am -

image text in transcribedimage text in transcribedimage text in transcribed

Lab 2: Singly-linked Lists Submit Assignment File Types cpp Due Wednesday by 11:59pm Points 10 Submitting a file upload Available Feb 8 at 12am - Feb 18 at 11:59pm 11 days For this lab, you are welcome to work with other students (maximum of 5, yourself included). If you are working with other students, then make sure to: Write all names in the header. Submit ONLY ONE COPY of the lab (I will give a grade to all the students whose names are included in the name header). What to turn in: The Functions.cpp file (do not worry if Canvas modifies the name slightly). INSTRUCTIONS For this lab, use these files: AnyList.h AnyList.cpp a Functions.cpp To test each function use these files one at a time: TestingGetMin.cpp Testing HaveThree.cpp TestingPreFour.cpp 3 + TestingGetMin.cpp Testing HaveThree.cpp Testing PreFour.cpp o Updated preFour testing output (Missing "List is empty statement") Elements inserted: 4 4 Your list is: 4.4 Get results... Expected calling object: Your calling object: List is empty. Expected parameter object: 4.4 Your parameter object: 4.4 Testing CommonEnds.cpp Implement the functions listed below as members of the AnyList class by writing the declaration in the AnyList.h file and the definition in the Functions.cpp file. Function getMin . The function traverses the list and returns the minimum (smallest) value found. o Assumptions: List has at least one element. All values are greater than zero. Function haveThree o The function returns true if the value 3 appears in the calling list exactly 3 times and no 3's are next to each other. After implementing and testing your function, analyze your code and make sure it is efficient. . Example: . 3, 1, 3, 1, 3 => true 3, 1, 3, 3 => false . 3, 4, 3, 3, 4 => false Assumptions: List has at least one element. Function prefour . Parameter: An object of the class AnyList. o Given a non-empty singly-linked list, the function copies all elements from the parameter list that come before the first 4 into the calling object in reverse order. o Example: Parameter object: 1, 2, 7, 5, 4, 1 => Calling object becomes: 5, 7, 2, 1 Parameter object: 3, 1,4 => Calling object becomes: 1,3 Parameter object: 1, 4,4 => Calling object becomes: 1 Assumptions: The calling object is empty. The parameter list contains at least one 4. Function commonEnds - Parameter: An object of the class AnyList. o The function returns true if the calling object and the parameter object have the same first element AND the same last element. . Example: Calling object: 1, 2, 3 => Parameter object: 1, 4,3 => true Calling object: 5, 6, 1, 4 => Parameter object: 5, 3, 1, 7, 4, 3, 4 => true Calling object: 3, 4, 5 => Parameter object: 3,5 => true o Assumptions: Both lists have at least one element. Below you can find a link to a checklist to help you implement your code correctly. Please note that this checklist is NOT comprehensive. Checklista Lab 2: Singly-linked Lists Submit Assignment File Types cpp Due Wednesday by 11:59pm Points 10 Submitting a file upload Available Feb 8 at 12am - Feb 18 at 11:59pm 11 days For this lab, you are welcome to work with other students (maximum of 5, yourself included). If you are working with other students, then make sure to: Write all names in the header. Submit ONLY ONE COPY of the lab (I will give a grade to all the students whose names are included in the name header). What to turn in: The Functions.cpp file (do not worry if Canvas modifies the name slightly). INSTRUCTIONS For this lab, use these files: AnyList.h AnyList.cpp a Functions.cpp To test each function use these files one at a time: TestingGetMin.cpp Testing HaveThree.cpp TestingPreFour.cpp 3 + TestingGetMin.cpp Testing HaveThree.cpp Testing PreFour.cpp o Updated preFour testing output (Missing "List is empty statement") Elements inserted: 4 4 Your list is: 4.4 Get results... Expected calling object: Your calling object: List is empty. Expected parameter object: 4.4 Your parameter object: 4.4 Testing CommonEnds.cpp Implement the functions listed below as members of the AnyList class by writing the declaration in the AnyList.h file and the definition in the Functions.cpp file. Function getMin . The function traverses the list and returns the minimum (smallest) value found. o Assumptions: List has at least one element. All values are greater than zero. Function haveThree o The function returns true if the value 3 appears in the calling list exactly 3 times and no 3's are next to each other. After implementing and testing your function, analyze your code and make sure it is efficient. . Example: . 3, 1, 3, 1, 3 => true 3, 1, 3, 3 => false . 3, 4, 3, 3, 4 => false Assumptions: List has at least one element. Function prefour . Parameter: An object of the class AnyList. o Given a non-empty singly-linked list, the function copies all elements from the parameter list that come before the first 4 into the calling object in reverse order. o Example: Parameter object: 1, 2, 7, 5, 4, 1 => Calling object becomes: 5, 7, 2, 1 Parameter object: 3, 1,4 => Calling object becomes: 1,3 Parameter object: 1, 4,4 => Calling object becomes: 1 Assumptions: The calling object is empty. The parameter list contains at least one 4. Function commonEnds - Parameter: An object of the class AnyList. o The function returns true if the calling object and the parameter object have the same first element AND the same last element. . Example: Calling object: 1, 2, 3 => Parameter object: 1, 4,3 => true Calling object: 5, 6, 1, 4 => Parameter object: 5, 3, 1, 7, 4, 3, 4 => true Calling object: 3, 4, 5 => Parameter object: 3,5 => true o Assumptions: Both lists have at least one element. Below you can find a link to a checklist to help you implement your code correctly. Please note that this checklist is NOT comprehensive. Checklista

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

Students also viewed these Databases questions

Question

What are the typical weathering products of granite?

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago