Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this program you will add and test 2 new member functions to the IntsList cl

ID: 3753397 • Letter: F

Question

For this program you will add and test 2 new member functions to the IntsList class posted on the website. The two member functions are el, int RQS) Assuming that the positions of elements of a list begin numbering at 1 and continue to the end of the list, you will insert a new node with info value el at position pos. Res will become the position of the new node in the modified list. For example, if Res = 1, insert the new node at the head of the list. If pos2, for example, insert the new node BEFORE the node currently at position 2. If the list is empty prior to insertion, insert the new node in the list and adjust head and tail pointers. If pos is too large, don't do anything. If pos is 0 or negative, don't do anything pos) Assume position of elements are defined as above. If pos is zero or negative, do nothing. If the list is empty prior to the request to delete a node, do nothing. If pos is too large, do nothing. To aid in verifying results, you should use the following modified version of printall. This requires: include voi string Jasa) soast cout,

Explanation / Answer

Hi! please follow the below instructions to meet our following functions
here i am providing the solution for whatever you want the functions
public:
static void reverse(struct node** head)
{
struct node* prev = NULL;
struct node* current = *head;
struct node* next = NULL;
while (current != NULL)
{
next = current->next;  
current->next = prev;
prev = current;
current = next;
}
*head = prev;
}
public:
int search(int id_value)
{
int index=0;
struct node* temp3 = temp1;
while(temp3!=NULL)
{
if(id_value==temp3->uniqueid)
{
return index;
}
temp3=temp3->next;
index++;
}
return -1;
}
public:
void addnewnode(struct node** head,int serialno,char firstName[],char LastName[],int idvalue)
{
struct node* new_node=(struct node*)malloc(sizeof(struct node));
last=*head;
new_node->serial_no=serialno;
strcpy(new_node->FirstName,firstName);
strcpy(new_node->LastName,LastName);
new_node->uniqueid=idvalue;
new_node->next=NULL;
while (last->next != NULL)
last = last->next;
last->next = new_node;
}
public:
void DeleteNode(struct node **head, int position)
{
if (*head == NULL)
return;
struct node* temp = *head;
if (position == 0)
{
*head = temp->next;
free(temp);
return;
}
for(int i=0; temp!=NULL && i<position-1; i++)
temp = temp->next;
if(temp == NULL || temp->next == NULL)
return;
last = temp->next->next;
free(temp->next);
temp->next = last;
}
if you want full source code ,please ping me as comment.

Complete Source Code:=
==================
#include <iostream>
#include <iomanip>
#include <string.h>
#include <stdlib.h>
#include <fstream>
using namespace std;
struct node
{
char FirstName[100];
char LastName[100];
int uniqueid,serial_no;
struct node *next;
};
struct node array[100];
struct node *first=NULL,*last=NULL,*swapping,*temp1=NULL;
class LinkedList
{
public:
char First_Name,Last_Name;
int unique_id;
int exam1_grade,exam2_grade,final_Grade;
public:
void printList( struct node* head)
{
static int i=0;
if (head->next == NULL)
{
return;
}
else
{
if(i==0)
{
cout<<"-------------------------------------------------------"<<endl;
cout<<"S.No"<<setw(15)<<"FirstName"<<setw(15)<<"LastName"<<setw(15)<<"Unique_id"<<endl;
cout<<"------------------------------------------------------"<<endl;
i++;
}
cout<<head->serial_no<<setw(15)<<head->FirstName<<setw(15)<<head->LastName<<setw(15)<<head->uniqueid<<endl;
printList(head->next);
}
}
public:
static void reverse(struct node** head)
{
struct node* prev = NULL;
struct node* current = *head;
struct node* next = NULL;
while (current != NULL)
{
next = current->next;  
current->next = prev;
prev = current;
current = next;
}
*head = prev;
}
public:
int search(int id_value)
{
int index=0;
struct node* temp3 = temp1;
while(temp3!=NULL)
{
if(id_value==temp3->uniqueid)
{
return index;
}
temp3=temp3->next;
index++;
}
return -1;
}
public:
void addnewnode(struct node** head,int serialno,char firstName[],char LastName[],int idvalue)
{
struct node* new_node=(struct node*)malloc(sizeof(struct node));
last=*head;
new_node->serial_no=serialno;
strcpy(new_node->FirstName,firstName);
strcpy(new_node->LastName,LastName);
new_node->uniqueid=idvalue;
new_node->next=NULL;
while (last->next != NULL)
last = last->next;
last->next = new_node;
}
public:
void DeleteNode(struct node **head, int position)
{
if (*head == NULL)
return;
struct node* temp = *head;
if (position == 0)
{
*head = temp->next;
free(temp);
return;
}
for(int i=0; temp!=NULL && i<position-1; i++)
temp = temp->next;
if(temp == NULL || temp->next == NULL)
return;
last = temp->next->next;
free(temp->next);
temp->next = last;
}
public:
int smallestElement(struct node* head)
{
int min = INT_MAX;
while (head != NULL)
{
if (min > head->uniqueid)
min = head->uniqueid;
head = head->next;
}
return min;
}
public:
int largestElement(struct node* head)
{
int max = INT_MIN;
while (head != NULL)
{
if (max < head->uniqueid)
max = head->uniqueid;
head = head->next;
}
return max;
}
};
int main()
{
LinkedList obj;
char firstname[50];
char lastName[50];
char tempstr[100];
int id,sno,serialno=13,retval=0;
char option,choice;
ifstream myfile;
myfile.open("linkedlist.data");
if(myfile.is_open())
{
for(int i=0;i<13;i++)
{
temp1 = (struct node*)malloc(sizeof(struct node));
memset(firstname,0,sizeof(firstname));
memset(lastName,0,sizeof(lastName));
myfile>>sno;
myfile>>firstname;
myfile>>lastName;
myfile>>id;
temp1->serial_no=sno;
strcpy(temp1->FirstName,firstname);
strcpy(temp1->LastName,lastName);
temp1->uniqueid=id;
temp1->next=swapping;
swapping=temp1;
}
obj.reverse(&temp1);
cout<<" The Content From The File is "<<endl;
obj.printList(temp1);
}
else
{
cout<<" ! Couldn't Able to Open The File"<<endl;
}
while(true)
{
cout<<" ****** MENU *****"<<endl;
cout<<"Enter 'P'.To print the List "<<endl;
cout<<"Enter 'a' To Add a New Node to the List"<<endl;
cout<<"Enter 'd' To Delete a Node from the List"<<endl;
cout<<"Enter 's' To Search a Node in the LinkedList"<<endl;
cout<<"Enter 'm' to Find Maximum number(Serial No)"<<endl;
cout<<"Enter 'l' to Find Minim Number(Serial No)"<<endl;
cout<<"Enter 'q' To Quit from the Menu"<<endl;
cout<<"Please Enter Any Option"<<endl;
cin>>option;
switch(option)
{
case 'p':
obj.printList(temp1);
break;
case 'a':
serialno++;
label:
cout<<" Please Enter FirstName"<<endl;
cin>>firstname;
cout<<" Please Enter LastName"<<endl;
cin>>lastName;
cout<<" Please Enter Unique id:"<<endl;
cin>>id;
cout<<" You Entered! "<<firstname<<" "<<lastName<<" "<<id<<endl;
cout<<" Correct?(Y/N)"<<endl;
cin>>choice;
if(choice=='Y'||choice=='y')
{
retval=obj.search(id);
if(retval!=-1)
{
cout<<" The Unique id is Already Exist try with Different!"<<endl;
}
else
{
obj.addnewnode(&temp1,serialno,firstname,lastName,id);
cout<<" New node Details are Added Successfully"<<endl;
cout<<" The New List is"<<endl;
obj.printList(temp1);
}
}
else
goto label;
break;
case 's':
cout<<" Please Enter Unique id:"<<endl;
cin>>id;
retval=obj.search(id);
if(retval!=-1)
{
cout<<" The Unique id is Exist try with Different!"<<endl;
}
else
cout<<" The Id is found!"<<endl;
break;
case 'd':
cout<<" Please Enter the Unique id to remove from the List"<<endl;
cin>>id;
retval=obj.search(id);
if(retval==-1)
{
cout<<" The id is Not Exist Please try again"<<endl;
}
else
{
obj.DeleteNode(&temp1,retval);
cout<<" The Node is Deleted Successfully"<<endl;
cout<<" The New List is:"<<endl;
obj.printList(temp1);
}
break;
case 'm':
cout<<" The Maximum Element in the List is:"<<obj.largestElement(temp1)<<endl;
break;
case 'l':
cout<<" The Smallest Element in the List is:"<<obj.smallestElement(temp1);
break;
case 'q':
exit(0);
default:
cout<<" Invalid Option!"<<endl;
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote