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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 16:30
How to do this programming flowchart?
Answers: 3
question
Computers and Technology, 24.06.2019 13:30
Which type of excel chart should be used to track students’ progress on test grades? line column bar pie
Answers: 2
question
Computers and Technology, 24.06.2019 14:30
Which computer network component connects two different networks together and allows them to communicate? a is a node (or a device) that connects two different networks together and allows them to communicate.
Answers: 1
question
Computers and Technology, 24.06.2019 18:00
Hacer un algoritmo que me permita ingresar el nombre de una parcela de terreno y muestre junto al mensaje “tipo de suelos: suelos fumíferos, ¡excelente!
Answers: 1
You know the right answer?
Read these instructions carefully to ensure your implementation is correct. Write the function odd...
Questions
question
Mathematics, 08.04.2021 20:20
question
Law, 08.04.2021 20:20
question
Mathematics, 08.04.2021 20:20
question
Mathematics, 08.04.2021 20:20
Questions on the website: 13722360