cribe the following code. Node *pre = new Node; Node *cur = new Node; Node *temp = new Node; cur = head; for (int i=1;inext; temp->data=value; pre->next=temp; temp->next=cur; ect one: a. A function that will insert a node in an arbitrary position b. Identifies the current and previous data element in the linked list c. None of the choices

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 3SA
icon
Related questions
Question
Subject is C++ Programming
Describe the following code.
{
Node *pre = new Node;
Node *cur = new Node;
Node *temp = new Node;
cur = head;
for (int i=1;i<pos;i++)
{
pre = cur;
cur = cur->next;
temp->data=value;
pre->next=temp;
temp->next=cur;
Select one:
a. A function that will insert a node in an arbitrary position
O b. Identifies the current and previous data element in the linked list
c. None of the choices
O d. Traverse a linked list
Transcribed Image Text:Describe the following code. { Node *pre = new Node; Node *cur = new Node; Node *temp = new Node; cur = head; for (int i=1;i<pos;i++) { pre = cur; cur = cur->next; temp->data=value; pre->next=temp; temp->next=cur; Select one: a. A function that will insert a node in an arbitrary position O b. Identifies the current and previous data element in the linked list c. None of the choices O d. Traverse a linked list
Describe the following code.
Node *current=new Node;
Node *previous=new Node;
current=head;
while (current->next!=NULL)
{
previous=current;
current=current->next;
tail=previous;
previous->next=NULL;
delete current;
Select one:
a. Delete all the elements
b. Delete the header and the current element of the linked list
c. None of the choices
O d. Delete an element on a particular position
Transcribed Image Text:Describe the following code. Node *current=new Node; Node *previous=new Node; current=head; while (current->next!=NULL) { previous=current; current=current->next; tail=previous; previous->next=NULL; delete current; Select one: a. Delete all the elements b. Delete the header and the current element of the linked list c. None of the choices O d. Delete an element on a particular position
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning