To rotate the Doubly linked list first check whether the given N is greater than the length of the list or not. If N is greater than the size of the list then deduce it in the range of linked list size by taking modulo with the length of the list. After that subtract the value of N from the length of the list. Now the problem reduces to the counter-clockwise rotation of a doubly-linked list by N places.
#include <stdio.h> struct node{ int data; struct node *previous; struct node *next; }; struct node *head, *tail = NULL; int size = 0; void addNode(int data) { struct node *newNode = (struct node*)malloc(sizeof(struct node)); newNode->data = data; if(head == NULL) { head = tail = newNode; head->previous = NULL; tail->next = NULL; } else { tail->next = newNode; newNode->previous = tail; tail = newNode; tail->next = NULL; } size++; } void rotateList(int n) { //Initially, current will point to head struct node *current = head; //n should not be 0 or greater than or equal to number of nodes present in the list if(n == 0 || n >= size) return; else { //Traverse through the list till current point to nth node //after this loop, current will point to nth node for(int i = 1; i < n; i++) current = current->next; //Now to move entire list from head to nth node and add it after tail tail->next = head; //Node next to nth node will be new head head = current->next; //Previous node to head should be NULL head->previous = NULL; //nth node will become new tail of the list tail = current; //tail's next will point to NULL tail->next = NULL; } } void display() { struct node *current = head; if(head == NULL) { printf("List is empty\n"); return; } while(current != NULL) { printf("%d ", current->data); current = current->next; } printf("\n"); } int main() { addNode(1); addNode(2); addNode(3); addNode(4); addNode(5); printf("Original List: \n"); display(); rotateList(3); printf("Updated List: \n"); display(); return 0; }

If you find the Answer helpful doo, please upvote..
hw3 Data Structure: Please write programs and finish the question in C language: thank you (You...
This is a c programming problem.
Would you please help me to write this problem???
I really appreciate it if you add comments for explanation step
by step.
Thank you.
Reverse a Doubly linked list using recursion: Given a doubly linked list. Reverse it using recursion. Original Doubly linked list: next pointer - DDHIHI Null prev painter Reversed Doubly linked list: next pointer Start Pointer Null prev pointer Include: a) A struct for a node of the doubly linked list....
(WRITE THIS PROGRAM IN C LANGUAGE).Before I ask the question, i'm just letting you know that I asked this question before but I unfortunately the answer was wrong, in fact, it didn't even answer my questions. So please make an effort to answer this question. In this question, we will learn about a variant of linked list called \doubly Linked List". In addition to the \next" pointer pointing to the next node in the list, a node in a doubly...
implement a doubly-linked list in C. Each node in the linked list should contain a string, a pointer to the previous node (or NULL), and a pointer to the next node (or NULL). The nodes should be sorted by their strings. struct node_t { char* str; struct node_t* prev; struct node_t* next; } To maintain the doubly-linked list, you should keep a pointer to the head node of the list (or NULL if the list is empty), and a pointer...
***Using C++ and also please label "a" and "c" accordingly.
Thank you!!****
a) Write the member function void deleteNode() that will delete
the first node from the linked list.
b) Modify the LList to create a data member Node *cur that
points to the current node. Write the following member
functions:
• void forward() that moves the cur pointer to the next
node.
• void backward() that moves the cur pointer to the previous
node.
• void delete() that removes...
Please write a c++ header file, class implementation file and
main file that does all of the following and meets the requirements
listed below. Also include a Output of your code as to show that
your program works and functions properly.
EXERCISING A DOUBLY-LINKED LIST CLASS
This project consists of two parts, the second of which appears
below. For the first part, write a class that
implements an unordered list abstract data type
using a doubly-linked list with pointers to...
Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a function that finds if a given value is present in a linked-list. The function should look for the first occurrence of the value and return a true if the value is present or false if it is not present in the list. Your code should work on a linked-list of any size including an empty list. Your solution must be RECURSIVE. Non-recursive solutions will...
In this assignment you are to utilize the Node data structure provided on Blackboard. In this assignmet you are to write a main program that implements two methods and a main method as their driver. So, only main and two methods with it. Note: You may not use any of the LinkedList class provided on Blackboard, you may use the methods in it as a guide (you should actually look at them) but you cannot use any of the methods...
Write the pseudo code for function node* list search(node* head ptr, const node::value type& target); where head ptr is the head pointer of a linked list. The function returns a pointer to the first node containing the specified target in its data field. If there is no such node, the null pointer is returned. You can also use C++ code as you prefer.
can
you guys please help me with these questions thank you
9.Given a Double Linked-List that contains the values in order: 1,2,3,4,5; and the following class declarations: class List private: Node* head; public: PrintBackwards (); class Node{ friend class List; private: int value; Node* next; Node* prev; Write the algorithm PrintBackwards that prints the whole list backwards. So your functionshould output: “ 5,4,3,2,1" Extra Credit if you instead implement the algorithm for a single linked-list (i.e. only using the Node*...
enum {FALSE=0, TRUE}; #define MAXBUFF 1024 #define SMALLBUFF 10 /* The LinkNode type is used as an element of a linked list ** implementation of a stack of tree nodes. */ typedef struct link_t LinkNode; typedef LinkNode *LinkNodePtr; /* The TreeNode type is used as an element of a binary "parse" tree. ** Tree nodes are created while parsing the RPN expression and ** stored on a stack until it's time to place them. */ typedef struct tree_t TreeNode; typedef...