Read carefully. Please make sure to include A LOT of comments on your code. I wa
ID: 3743601 • Letter: R
Question
Read carefully. Please make sure to include A LOT of comments on your code. I want to make sure I understand.
The correct solution WITH comments will immediately receive a thumbs up.
Write a program to create and fill a circular singly linked list with computer science (you can ask the user to enter a sentence e.g I Love C++)) Computer science Round 1: start from head C and select every other letter remove it and put it in a removal list (add at the end function) coptrsine mueAcec round 2:cotsn mue*cec prie round 3:cos mue cec prie trn round 4: co mueAcec prie tn s round 5: muencec prie tn s co Count the number of rounds needed to empty the circular list into removal single list Print the contents of the removal list Advanced option: Try your program with different sentences and record the time For example Computer science I love programming in c++ 12 sec 10 secExplanation / Answer
Lets the program uisng c
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data; //delare variable data//
struct node *next; //declare pointer next
};
void sortInsert(struct node *head, struct node *new)
{
struct node *current = *head; //current node point to header
if(current == NULL) //if current is null
{
new-->next = new; //then new node point itself only
head = new; //header point to the new node beacuse it's only node in linked list
}
else if(current-->data >= new -->data)
{
while(current->next != head)//if current node is not head
{
current = current->next;// current node point to next
current-->next=new//current node point to new
new-->next = *head; //point to head
current-->next = node; // current point to head
}
})
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.