Please can you help me with the following question?
An iterative version of the C++ function TransactionList::getTransactionsForDate is given below. It can be applied to any list of transactions and returns the list of all the transactions for the given date. It only works when the date given is valid.
Write an equivalent recursive version of that function so that it can be used in the same way and produces the same result.
TransactionList TransactionList::getTransactionsForDate(
const Date& date) const {
assert ( date.isValid());
TransactionList copyTrl( *this);
TransactionList tempTrl;
while ( ! copyTrl.isEmpty() )
{
if ( copyTrl.first().getDate() == date)
tempTrl.addAtEnd( first());
copyTrl.deleteFirst();
}
return tempTrl;
}