Write a function that adds the values of the nodes at the beginning and end of a circular linked list and adds the result as the last element of the list. You can assume that there are at least two elements in the list.
//C code
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
int data;
struct node*next;
}Node;
void add(Node*head){
Node* current = head->next;
while(current->next != head) current =
current->next;
int result = current->data + head->data;
Node* newNode = (Node*) malloc(sizeof(Node));
newNode->data = result;
newNode->next = current->next;
current->next = newNode;
}
Write a function that adds the values of the nodes at the beginning and end of...
Assume we have a linked list with 12 nodes pointed to by FIRST. Write a function that deletes the first node. Write a function that deletes the 7th node. Write a function that deletes the last node.
Write a function to implement linked list consisting of five nodes. Store the data in the nodes in the order given below. Also, write a function to display the data stored in the implemented linked list. in C++ programming George, Paul, Ross, Joe, Elaine, Robert1 Insert three nodes in between second node and third node in the linked list that you implemented in problem 1. Store the following data in the new (inserted) nodes in the following order. (You have...
Write a function to implement linked list consisting of six nodes. Store the data in the nodes in the order given below. Also, write a function to display the data stored in the implemented linked list. in C++ programming use these as names as nodes George, Paul, Ross, Joe, Elaine, Robert1. Insert three nodes in between second node and third node in the linked list that you implemented in problem 1. Store the following data in the new (inserted) nodes...
Given a single linked chain of nodes with positive integers, write an algorithm in pseudocode to rearrange the nodes in one pass in such a way that all integers that are odd appear at the end. The relative order of the elements does not need to remain the same. List all the steps in the proper order that are necessary to rearrange the nodes, show how the next pointers are being changed. Each data element should “stay” in its original...
use python
In class, we've studied Singly-Linked Lists which are made of nodes that point at subsequent nodes. One of the biggest annoyances with Linked Lists is the difficulty of going backwards through a list (such as getting the previous node or traversing the list backwards). An intuitive solution to this inefficiency is the doubly-linked list, which adds pointers to previ- ous nodes. Doubly-Linked Lists are not very different from Singly-Linked Lists, but are far more common because they are...
use python
In class, we've studied Singly-Linked Lists which are made of nodes that point at subsequent nodes. One of the biggest annoyances with Linked Lists is the difficulty of going backwards through a list (such as getting the previous node or traversing the list backwards). An intuitive solution to this inefficiency is the doubly-linked list, which adds pointers to previ- ous nodes. Doubly-Linked Lists are not very different from Singly-Linked Lists, but are far more common because they are...
use python
In class, we've studied Singly-Linked Lists which are made of nodes that point at subsequent nodes. One of the biggest annoyances with Linked Lists is the difficulty of going backwards through a list (such as getting the previous node or traversing the list backwards). An intuitive solution to this inefficiency is the doubly-linked list, which adds pointers to previ- ous nodes. Doubly-Linked Lists are not very different from Singly-Linked Lists, but are far more common because they are...
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...
Please Write Pseudocode or Python code!
Thanks!
P1. b) is the following:
W1. (6 marks) Write the pseudocode for removing and returning only the second element from the Stack. The top element of the Stack will remain the top element after this operation. You may assume that the Stack contains at least two items before this operation. (a) Write the algorithm as a provider implementing a Stack using a contiguous memory implementation. You can refer to the implementation given in...
write the function definition to create a linked list of 8 nodes that contain randomly generated characters between .с. 99) and· 119). The function should return t new linked list. (HINT: keep in mind the member function defined in question 2). 3.