Reference no: EM131145357
The task for this problem is:
1) Create a Node structure. Initialize the number variable to -1 and the nextNode pointer to nullptr.
2) Add the even numbers between 0 and 40 to the list. Your list will therefore have 20 numbers in it at that point.
3) Display the list by using the displayList() function. 4) Go through the list and insert the odd numbers into their appropriate places by using the insertAfter() function. 5) Display the list again. 6) Delete the list.
These are my functions for the task:
1) Node * addNodeToEnd (Node * lastNode, int num); This function will add a node to the end of the list and return a pointer to it. lastNode will hold a pointer to the current last node in the list. The new node should be dynamically allocated inside the function (which means, of course, that all nodes will have to be deleted later) and inserted after lastNode.
The variable number should be set to num. The nextNode pointer should be set to nullptr.
2) void displayList (Node * firstNode); This function will display the elements of the list, ten numbers per line, each one in a five byte field. It makes no change to the list.
3) int getNumOfElements (Node * firstNode); This function should traverse the list, count how many elements are in it, and return that number. (Note that the end of the list can be detected by the presence of the nullptr.) You should not count the dummy node at the beginning as an element in the list. (If the dummy node is all that is there, then the size of the list is 0.)
4) At least one of the following functions. Either one or both will suffice. You can choose as needed.
a) Node * getElemAtPos (int pos); This function should return a pointer to the element at position pos. The function should call the getNumOfElem() function before it accesses the list. If pos is out of range, it should print an error message and return nullptr. If pos is within range, the function should return a pointer to the correct element.
b) Node * getNodeWithValue (int value); This function should traverse the list and return a pointer to the first element that has the value value. If value is not in the list, it should return a nullptr.
5) Node * insertAfter (Node * currNode, int num); This function will insert a new node into the list immediately after the node pointed to by currNode.
The new node should be dynamically allocated. The function will set the number value of the next node to num and return a pointer to the new node. That pointer can be used for the next insertion.
6) void deleteList (Node * firstNode); This function will traverse the entire list, deleting each element in turn. It is an essential cleanup function that will be executed when everything else is done. function node is this: struct Node { int number; Node * nextNode; };
Was there anything unethical about the presidents actions
: Riverside Automotive Corp. is a medium-sized wholesaler of automotive parts. It has 10 stockholders who have been paid a total of $1 million in cash dividends for 8 consecutive years.
|
Describe how socioeconomic status affects health care
: Socioeconomic status influences health and drives diversity in the context of health disparities. Based on readings provided, describe how socioeconomic status affects health care. Can diversity in the health care workforce promote better health c..
|
Importance of quality partnering and strategic alliances
: Discuss the importance of quality partnering and strategic alliances. Discuss the various forms of quality partnering and strategic alliances. Discuss the importance of quality culture
|
How you would implement the planning process
: Provide an example of a negotiation situation from the experience, where one of the four ways directly impacted the selection of your strategy. Analyze how you would implement the planning process into a negotiation situation to achieve your goals
|
Create a node structure
: Create a Node structure. Initialize the number variable to -1 and the nextNode pointer to nullptr - Add the even numbers between 0 and 40 to the list. Your list will therefore have 20 numbers in it at that point.
|
Identify the current ideas about how diversity
: Review studies of health disparities driven by socioeconomic status, as well as the module resources. Identify the current ideas about how diversity in socioeconomic status is measured, what the different predictors of health are, gaps in current ..
|
What is the expected value of a pull on the slots
: Casinos advertise a 95% payback for their slot machines. This means that for a $1 stake, a gambler can expect to get 95 cents back. a) What does 95% payback mean in terms of the expected value of a play on the slot machines? i.e. What is the expected..
|
What happens to the expected real interest rate
: What happens to the expected real interest rate? Explain why the subsequent path of the real exchange rate satisfies the real interest parity condition.
|
Identify the three most important consumer factors
: Iidentify the three most important consumer factors you think are relevant to the customers of your product or service offering. Explain your choices.
|