Write a program in C programming:
1. Build a doubly linked list given the keyboard inputs.
2. Perform a bubble sort (in ascending order of the value) for the above linked list and print the list out to the screen. For comparison purposes, please also print the unsorted linked list.
Your doubly linked list node data structure is defined as follows:
struct node {
int value;
struct node *next;
struct node *prev;
};
NOTE: YOU ARE NOT ALLOWED TO MODIFY THE ABOVE DEFINITION, OTHERWISE YOU WILL RECEIVE ZERO.
A pre-prepared input example is listed below:
30 20 50 70 10
Given the input above, your program should build a linked list with 5 nodes. Given the above 5 data, your unsorted linked list should look like: 30<==>20<==>50<==>70<==>10. Then your program should print out the sorted list: 10<==>20<==>30<==>50<==>70.
Your program's implementation must include the following features:
- Your program must be compiled from 3 source files: main.c (Handles input and output, as well as top-level program logic), node.h (Declares the data structure, e.g., struct node, and function bubblesort(), which sorts a given doubly linked list in ascending order), and printlist(), which prints a linked list to the screen.
- node.c (Defines the function bubblesort() and printlist(), as declared in node.h).
- You must write bubblesort() and the rest of the project by yourself. If your code is "adopted" from the Internet, e.g., geeksforgeeks.org, or any other sources, your submission will not be graded and will be considered a violation of the ethics policy.
- The main function must use the scanf() function call to read the input data from the keyboard. The number of data (in the data file) is not predetermined.
- The function bubblesort() must be declared exactly as follows:
- Return value: struct node *.
- Argument (only one): struct node *, which is the head of the given linked list. Note that you must implement the bubblesort() function by yourself and cannot use any existing implementation from another library. You have to use the bubblesort algorithm instead of another sorting algorithm.
- The function printlist() must be declared exactly as follows:
- Return value: void.
- Argument (only one): struct node *, which is the head of the given linked list.