Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91900840
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question what will be the source and destination ip

Question : What will be the source and destination IP addresses the response packet after the router forwards it to the private network? The response must be typed, single spaced, must be in times new roman font (size 12 ...

A different ethanol processing facility costs 800000 to

A different ethanol processing facility costs $800,000 to construct but will instead last forever. Every year (starting the year after  construction), it produces 10,000 barrels of ethanol and can charge a price of $4 pe ...

Relational algebrawrite a relational algebra expression

[Relational Algebra] Write a relational algebra expression that will output first name and last name of computer science major male students who have borrowed books from "University of Iowa Main Library". Relational Sche ...

Question wireless transmission please respond to the

Question: Wireless Transmission" Please respond to the following: • Organizations need to be careful about their wireless transmissions and controlling the reception of the wireless signal. Discuss ways that organization ...

Question squareroot write a function to determine the

Question : squareroot Write a function to determine the squareroot of a number. The squareroot of a number can be approximated by repeated calculation using the formula NG = 0.5(LG + N/LG) where NG stands for the next gu ...

Question describe specifically how the organization will

Question: Describe specifically how the organization will formulate a business performance plan, as follows: • Conduct a current situation analysis. • Determine the planning horizon. • Conduct an environmental scan. • Id ...

Access your browsers security settings and configure the

Access your browser's security settings and configure the browser to refuse all cookies or to prompt you before allowing a cookie. Restart the browser; then visit several different Web sites. Be sure to visit popular sit ...

Suppose our task is to distinguish between humans and

Suppose our task is to distinguish between humans and non-human objects in an image, which classifier would you choose and why? Decision trees, perceptrons or neural nets.

Switches are an integral part of networks they are the

Switches are an integral part of networks. They are the devices you utilize for host connectivity to the network. Please identify and discuss an attack that takes advantage of a weakness in switches.

Need help with calculation problem and design a program to

Need help with Calculation Problem and Design a program to input two numbers. Calculate the sum, the difference, the product, and the quotient. Display the answers. Car Rental Problem The Sports Car Rental Company rents ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As