Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 - Explanation In plain language, explain the base case ( s ) solutions ( and the condition when these should be performed )

Part 1- Explanation
In plain language, explain the base case(s) solutions (and the condition when these should be performed) for the following recursive problems below:
Walk up all of the stairs until you reach the top of a building
Find the sum of all numbers in a list
Respond to everyone on your list of unread emails
Traverse every node in a linked list (remember that we have methods to determine when the list ends!)
Sort all of the playing cards in your hand (order doesn't matter, ex: from Ace -> # -> King)
In plain language, explain the recursive case solutions to the following problems below. You should try to be specific in terms of the information you will need when peforming the next recursive step. Recursive function calls don't implicitly have memory of whatever happened before they were called!
Walk up all of the stairs until you reach the top of a building
Find the sum of all numbers in a list
Traverse every node in a linked list (remember that we have methods to determine when the list ends!)
Part 2- Implementation
For this section, be sure to indicate the base case(s) and recursive case as comments in your solution.
Write a recursive function, sumRangeR(), which will return the sum of all integers in an array of integers with length n, in a range starting from index start, to index end.
This function does not simply add all of the values in the array! If start is 3 and end is 7, then the function should return arr[3]+arr[4]+arr[5]+arr[6]+arr[7] and ignore the other values
Write a recursive function, helloAllR(), which will print a greeting to everyone in a given list of names, inputNames. inputNames is an array containing strings with length n.
Ex: length =3, inputNames ={"Hwan", "Tracie", "Yorbert"}, function prints: "Good morning, Hwan!" "Good morning, Tracie!" "Good morning, Yorbert!"
Write a recursive function, traverseLListR() that will start from a pointer to some input node (for example: "head" of a linked list), and will print out data for each node until the end of the list
Ex: linked list has nodes with values: 10=>6=>2=>8=>2=> nullptr
If node with value 6 has a pointer named startPtr, the function call should be traverseLListR(startPtr), and should output:
6=>2=>8=>2
Node class has a definition as shown below
class Node {
public:
int number;
Node* next = nullptr;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions