Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Program, assume there are a helper file and the main function implemented already Problem 3 Task: A circular linked list is one where the

C++ Program, assume there are a helper file and the main function implemented already

image text in transcribed

Problem 3 Task: A circular linked list is one where the last node in the list points to the first node ( tail->next is the first element in the list and none of them point to NULL ). Write a program that creates a circular linked list with a tail pointer and a function that shifts the list by n spaces. For example, if the list has 4 elements and shift(2) is called, the item that was previously the first element will be the third element, the item that was previously second will be fourth, and the item that was previously third will be first, etc. Requirements: 1. Implement a shift function: (you may change the function headers below to suit your implementation) Node* shift (Node *tail, int n); // example declaration This function should shift the linked list by n spaces. If n is greater than the length of the list, shift it by n mod length. Node* insertEnd (Node *tail, int val) // example declaration This function should insert a new element at the end of the linked list with a value of val void print(Node *tail); // example declaration The print function should print the list from beginning to end. Remember that the list begins with tail->next. 2. Write a main function that creates a circular linked list, then calls the functions in part (1) to shift the list and print. Clearly show that your function works properly for different sizes of linked lists and different values of n. 3. Test your code to make sure that it is successfully shifting, and that it can handle any edge cases you can think of

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

state what is meant by the term performance management

Answered: 1 week ago