Start New Discussion within our Software Development Community

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;
}

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.

I added these tags for you

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;

}

I'll help you first by saying this isn't your first post, it's your 11th, you should know how to use code tags by now. You should also know that we don't give help to those who don't show effort.

Comments
It's getting tiresome isn't it?
This article has been dead for over six months. Start a new discussion instead.