Question: Linked Lists You are given a linked list that contains N integers. You are to perform the following reverse operation on the list: Select all

Linked Lists

You are given a linked list that contains N integers. You are to perform the following reverse operation on the list:

Select all the subparts of the list that contain only even integers. For example, if the list is {1,2,8,9,12,16}, then the selected subparts will be {2,8}, {12,16}. Reverse the selected subpart such as {8,2} and {16,12}. The list should now be {1,8,2,9,16,12}.

Your node definition should consist of 2 elements: the integer value and a pointer to a node.

Sample Input

9 2 18 24 3 5 7 9 6 12 

Sample Output:

24 18 2 3 5 7 9 12 6

Note please fix this Space: An unexpected space was detected in the output

#include using namespace std; #define ll long int int main() { stacks; //object stack int n;cin>>n; //read input ll a[n]; for(int i=0;i>a[i]; for(int i=0;i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!