In this problem you will have to define the funciton void reverseList(List L) that takes a list and reverses the order of the elements. If L is an empty list, the function does nothing to it. if L is a singleton list, the function does nothing to it either! Example: Input: 4 1 2 3 4 Output: [4 3 2 1]
#include <stdio.h> #include <stdlib.h> struct Node{ long int info; struct Node* next; }; void insert(struct Node** head_addr, int new_info) { struct Node* new_node = (struct Node*)malloc(sizeof(struct Node)); new_node->info = new_info; new_node->next = (*head_addr); (*head_addr) = new_node; } void displayLinkedList(struct Node* head) { printf("["); struct Node* temp = head; while(temp != NULL) { printf("%ld ", temp->info); temp = temp->next; } printf("]"); }
reversed
Next
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)