subject

Read these instructions carefully to ensure your implementation is correct. Write the function odds which takes as input a linked list and modifies the input linked list to contain only the odd elements from the list. You must also return this list. The modified list must maintain the original order. Note: the input parameter is not pass-by-reference due to APT limitations, however, you are still expected to modify the incoming list, not make copies of nodes. Your linked list is represented by a pointer to a node; the node class is defined like so: class node { public: int data; node *next; }; For example, if odds is called with the list { 4,7,8, 2, 99, 34, -7} then input list must be modified to contain only { 7.99, -7). If the list would be empty, set it to nullptr. Your code must work for any valid list. Assume all libraries needed for your implementation and namespace std have already been included. Constraints For full credit, your answer must:
not create any new nodes
have no memory leaks
not use any auxiliary data structures (only nodes)
not change any data fields (only next fields)
modify the incoming list as well as return the resulting list
work for any valid list
run in O(N) time where N is the original number of nodes in the list

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:30, nickddj12
Kyle, a receptionist for a building supply company, recently won an award for saving his company money on their phone system. after being presented with kyle's research, the company changed the way in which it made long-distance phone calls and cut their expenses in this area by 75 percent. the new system the kyle's company most likely adopted was wired communications switching stations voip hdtv
Answers: 3
image
Computers and Technology, 22.06.2019 09:40, Tyrant4life
It is vital to research each of the services you plan to disable before implementing any change, especially on critical machines such as the: a. servers in the test environment. b. domain controller and other infrastructure servers. c. desktops that have previously been attacked. d. desktops used by upper-level management.
Answers: 2
image
Computers and Technology, 22.06.2019 15:30, DestinyK8033
Why would a programmer use the logical operator and in an if statement? a: when an action is to be taken that requires both conditions to be falseb: when an action is to be taken that requires both conditions to be truec: when an action is to be taken that requires the first condition to be falsed: when an action is to be taken that requires the second condition to be truei took the test and the answer is b.
Answers: 3
image
Computers and Technology, 22.06.2019 19:30, mitalichavez1
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 3
You know the right answer?
Read these instructions carefully to ensure your implementation is correct. Write the function odd...

Questions in other subjects:

Konu
Mathematics, 26.03.2020 09:53
Konu
Mathematics, 26.03.2020 09:55