During this activity, students will be able to:
This activity must be developed in the pre-assigned teams of two.
NOTE: The files needed to start this lab are available in the course’s GitHub repository under the folder “10. Recursion/recursion
”.
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)\):
Función | Descripción |
---|---|
|
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: 22-Nov-2021 * Authors: * A01770771 Kamala Khan * A01777771 Carol Danvers *----------------------------------------------------------*/
To deliver the recursion.cpp
file, please provide the following information:
Only one team member needs to upload the file.
Due date is Tuesday, November 22.