During this activity, students will be able to:
For this programming assignment, students are required to complete all work independently and are not permitted to use AI-assisted tools, such as GitHub Copilot, ChatGPT, Gemini, or similar platforms, to automatically generate code. Using AI tools in this way undermines the learning process and violates academic integrity policies. The purpose of this assignment is to assess your understanding and application of the concepts covered in the course. Failure to comply with these guidelines may result in academic penalties, including but not limited to a lower grade.
If you have any questions about the assignment or need clarification on any concepts, please do not hesitate to visit your instructor during office hours. Rely solely on your own knowledge, the course materials, and any authorized resources provided by the instructor.
This activity must be developed in the pre-assigned teams of two.
NOTE: The files needed to start this lab are available in this tarball file: recursion.tgz
. To uncompress, type at the Linux terminal:
tar xzf recursion.tgz
IntList
To solve this lab you must use the IntList
(list of integers) class, which is inspired by the lists supported by the Lisp programming language and its dialects. Its interface and implementation are fully provided in the intlist.h
and intlist.cpp
files. The functions available to manipulate objects of type IntList
are described below. You can assume that all these functions have a constant complexity runtime, i.e. \(O(1)\):
Function | Description |
---|---|
|
Returns the first element of list
|
|
Returns a list which is a copy of list
|
|
Returns a list which is a copy of list
|
|
Returns
|
NOTE: In addition to the functions mentioned in the above table, the IntList
class implements the following operations with the expected semantics: default constructor, copy constructor, initializer list constructor, destructor, assignment operator (=
), equality operator (==
), and the to_string
member function. Also, the left shift operator (<<
) is overloaded in order to print objects of type IntList
to output streams such as std::cout
.
Using C++, implement the functions described below using recursion in each and every one of them. The code must be placed in the recursion.cpp
file.
IMPORTANT: Before the definition of each operation you must include a comment that indicates its corresponding time complexity.
Function | Description |
---|---|
|
Returns the number of elements contained in list
|
|
Returns a list which is a copy of list
|
|
Returns the sum of all the elements contained in list
|
|
Returns a list where each element of list
|
|
Returns the last element of list
|
|
Returns a list which is a copy of list
|
|
Returns the largest element contained in list
|
|
Returns a list that is the result of concatenating lists
|
|
Returns a list where
|
|
Returns a copy of list
|
|
This function should implement the merge algorithm. Returns a list that is the result of interleaving, in ascending order, the elements of the lists
|
|
Returns
|
|
Returns a copy of list
|
|
Returns a list with the same elements as list
|
|
Returns a list of ones and zeros that represents the value in binary (base 2) of the integer
|
Test your code using the unit tests contained in the tests.cpp
file (contains a total of 66 assertions).
Place in a comment at the top of the recursion.cpp
source file the authors’ personal information (student ID and name), for example:
/*---------------------------------------------------------- * Lab #5: Recursion * * Date: 20-Nov-2024 * Authors: * A01770771 James Howlett * A01777771 Wade Wilson *----------------------------------------------------------*/
To deliver the recursion.cpp
file, please provide the following information:
Only one team member needs to upload the file.
Due date is Wednesday, November 20.