Assume entries in a linked list are of type struct listrec:
struct listrec
{
char value;
struct listrec *next;
};
Write a main() routine in which you create the following linked list:
| a | --|----> | c | --|-----> | w | --|----> NULL
Write a function called printlist that takes a pointer to the start of a linked list and prints out all the nodes in the list in sequence. The inferface of this function is
void printlist(listrec *start_of_linked_list)
{
// print out all the nodes in the list
…
}
In your main( ), you may have
void main( )
{
listrec *head_old;
head_old = (beginning memory address of the linked list)
printlist(head_old); // print out the information in the linked list
…
}
#include <stdio.h>
#include <stdlib.h>
struct listrec {
char value;
struct listrec *next;
};
typedef struct listrec listrec;
void printlist(listrec *start_of_linked_list) {
if(start_of_linked_list == NULL) {
printf("NULL\n");
} else {
printf("| %c | --|----> ", start_of_linked_list->value);
printlist(start_of_linked_list->next);
}
}
int main() {
listrec *head_old = NULL;
head_old = (listrec *)malloc(sizeof(listrec));
head_old->value = 'a';
head_old->next = (listrec *)malloc(sizeof(listrec));
head_old->next->value = 'c';
head_old->next->next = (listrec *)malloc(sizeof(listrec));
head_old->next->next->value = 'w';
head_old->next->next->next = NULL;
printlist(head_old); // print out the information in the linked list
return 0;
}


Assume entries in a linked list are of type struct listrec: struct listrec { char...
In C++
Assume entries in a linked list are of type struct
listrec:
struct listrec
{
struct listrec *prev;
float
value;
struct listrec *next;
};
listrec *head, *tail;
Write a main() routine in which the user is asked the
number of nodes to create in the list (number greater than or equal
to zero) then create the following type of linked list (use a loop
to initialize list) based on the number of nodes requested:
Write a...
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...
Given the following linked list structure called node: struct node { int val; struct node * ptrNext; }; Assume we have a single list created from this structure with a head pointer called ptrFirst which is declared in the global scope. a. Write a complete C function called CountEven to count all the even values in this singly linked list of arbitrary number of nodes using an iterative (non-recursive) approach. The function takes as parameter the pointer to the starting...
() Given the following structure definition and typedef for a linked list of strings: typedef struct node st node; struct node st { char *word; /* a valid string pointer or NULL */ node *next; /* next node in the list or NULL */ }; Write a C function, free list(), that takes as an argument one of these lists, possibly NULL, and frees all the strings as well as the list itself. Write robust code. void free list(node *list){
A linked list is constructed of nodes described by the following structure: struct node{ char data; struct node *next; }; Assume a linked list containing a sentinel node is constructed from the above nodes. Write a function named "count"-prototyped as int count(struct node*sent)- that accepts a pointer to the sentinel node; counts the number of data (non-sentinel) nodes containing the character 'A'; and returns that count as the function value.
Programming in C: I am trying to modify this linked list to be doubly linked list. I’m also trying to add a print in reverse function. I’m really struggling with how to change the insert function to doubly link the nodes without effecting the alphabetical sorting mechanism. Example of desired output: Enter your choice: 1 to insert an element into the list. 2 to delete an element from the list. 3 to end. ? 1 Enter a character: a The...
Using the provided Linked List example code, linkedlist.c, as an example Make a node struct that holds ints instead of strings. In your main, insert 25 to 75 random integers with range (0 to 100) into a linked list of your nodes. Use a random to determine how many to make. Write a function int sum(NodePointer current) that returns the sum of the integers in the list by looping through the linked list. Write a function int count(NodePointer current) that...
Please fill in the code to reverse a linked list. IN C++ #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; /* Link list node */ struct Node { int data; // your code here }; /* Function to reverse the linked list */ static void reverse(struct Node** head_ref) { // your code here } /* Function to push a node */ void push(struct Node** head_ref, int new_data) { // your code here } /* Function to print linked list...
Please fill in this code to reverse a linked list: (written in C/C++) #include #include #include using namespace std; /* Link list node */ struct Node { int data; // your code here }; /* Function to reverse the linked list */ static void reverse(struct Node** head_ref) { // your code here } /* Function to push a node */ void push(struct Node** head_ref, int new_data) { // your code here } /* Function to print linked list */ void...
Need some help creating a bubble sort for my linked list in C. Here are the structs used in my code: struct simulation { void *list; int et; /* in seconds */ }; struct plane { double x, y, altitude; char callsign[15]; struct simulation *sim; }; Here is the struct used in my linked list: struct Node { void *data; struct Node *next; }; Here is my insert function: //ComparisonFunction and FILE not...