SlideShare a Scribd company logo
Assignment is :
"Page 349-350 #4 and #5 Use the "Linked List lab" you have been working on in class and add
the two functions the questions are asking you to develop: divideMid and divideAt. Be sure to
include comments Use meaningful identifier names (constants where appropriate) Do not work
together; no two people should have identical work!?!? Turn in .cpp file AND Turn in a "print-
screen' of your output (press "print-screen' on keyboard, then 'paste' in MS-Word)"
How do you solve QUESTION #5 in the book data structures using c++ by D.S. Malik in Visiual
Studios using the linked list below with what is being asked? Please need help
Linked list :
#include
#include
using namespace std;
struct nodeType
{
int info;
nodeType *link;
};
void createList(nodeType*& first, nodeType*& last);
void printList(nodeType*& first);
void insertFront(nodeType*& first);
void insertBack(nodeType*& last);
void deleteFirst(nodeType*& first);
void deleteLast(nodeType*& last, nodeType* first);
int main()
{
nodeType *first, *last;
int num;
createList(first, last);
int choice;
while(true)
{
cout<<"1. Insert Front. 2. Insert Last. 3. Delete Front. 4. Delete Last. 5. Print List. 6. Exit.
";
cout<<"Enter your choice: ";
cin>>choice;
switch(choice)
{
case 1: insertFront(first); break;
case 2: insertBack(last); break;
case 3: deleteFirst(first); break;
case 4: deleteLast(last, first); break;
case 5: printList(first); break;
case 6: return 0;
default: cout<<"Invalid menu option. Try again."<>number;
while (number != -999)
{
newNode = new nodeType; // create new node
newNode->info = number;
newNode->link = NULL;
if (first == NULL)
{
first = newNode;
last = newNode;
}
else
{
last->link = newNode;
last = newNode;
}
cout<<"Enter an integer (-999 to stop): ";
cin>>number;
} // end of while-loop
} // end of build list function
void deleteFirst(nodeType*& first)
{
nodeType *temp;
temp= first;
first= temp->link;
delete temp;
return;
}
void deleteLast(nodeType*& last, nodeType* current)
{
nodeType *temp;
while(current->link != NULL)
{
temp=current;
current=current->link;
}
temp=last;
current->link=NULL;
delete temp;
last = current;
return;
}
void insertFront(nodeType*& front)
{
int num;
cout<<" Enter the number to insert: ";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= front;
front= newNode;
return;
}
void insertBack(nodeType*& last)
{
int num;
cout<<" Enter the number to insert: ";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= NULL;
last->link= newNode;
last = newNode;
return;
}
void printList(nodeType*& first)
{
cout<<"Inside printList...printing linked list... "<info << " ";
current = current->link;
}
cout<
#include
using namespace std;
struct nodeType
{
int info;
nodeType *link;
};
void createList(nodeType*& first, nodeType*& last);
void printList(nodeType*& first);
void insertFront(nodeType*& first);
void insertBack(nodeType*& last);
void deleteFirst(nodeType*& first);
void deleteLast(nodeType*& last, nodeType* first);
int main()
{
nodeType *first, *last;
int num;
createList(first, last);
int choice;
while(true)
{
cout<<"1. Insert Front. 2. Insert Last. 3. Delete Front. 4. Delete Last. 5. Print List. 6. Exit.
";
cout<<"Enter your choice: ";
cin>>choice;
switch(choice)
{
case 1: insertFront(first); break;
case 2: insertBack(last); break;
case 3: deleteFirst(first); break;
case 4: deleteLast(last, first); break;
case 5: printList(first); break;
case 6: return 0;
default: cout<<"Invalid menu option. Try again."<>number;
while (number != -999)
{
newNode = new nodeType; // create new node
newNode->info = number;
newNode->link = NULL;
if (first == NULL)
{
first = newNode;
last = newNode;
}
else
{
last->link = newNode;
last = newNode;
}
cout<<"Enter an integer (-999 to stop): ";
cin>>number;
} // end of while-loop
} // end of build list function
void deleteFirst(nodeType*& first)
{
nodeType *temp;
temp= first;
first= temp->link;
delete temp;
return;
}
void deleteLast(nodeType*& last, nodeType* current)
{
nodeType *temp;
while(current->link != NULL)
{
temp=current;
current=current->link;
}
temp=last;
current->link=NULL;
delete temp;
last = current;
return;
}
void insertFront(nodeType*& front)
{
int num;
cout<<" Enter the number to insert: ";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= front;
front= newNode;
return;
}
void insertBack(nodeType*& last)
{
int num;
cout<<" Enter the number to insert: ";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= NULL;
last->link= newNode;
last = newNode;
return;
}
void printList(nodeType*& first)
{
cout<<"Inside printList...printing linked list... "<info << " ";
current = current->link;
}
cout< otherList; Suppose myList points to the list with the elements: 34 65 18 39 27 89 12 (in
this order). The statement: myList divideAt (otherList, 18) divides myList into two sublists:
myList points to the list with the elements 34 65, and otherList points to the sublist with the
elements 39 27 89 12. 6. b. Write the definition of the function to implement the tion divide
template a. Add o write a program to test your function. the following operation to the class
dered inkedli st opera-
Solution
Explanation :-
----------------------------
1.Take
nodeType *first1, *last1;
First and last for the divided list
2. Add Choice "6" for Divide
3.When user enter choice
Ask index where to break the list
When user enters the index , then break the list there
3) After User enters the index of item where to break the list
First find the item at the index
4)Check the method
/**
* first---> start of main list
* last ----> last of main list
* first1---> start of new list after list
* last1 ----> last of new listafter list
* item ---> item at which we have to split
*/
void breakList(nodeType*& first, nodeType*& last,nodeType*& first1, nodeType*&
last1,nodeType*item);
5)To break the list at middle , just give the middle index
Programme :-
----------------------------
#include
#include
using namespace std;
struct nodeType
{
int info;
nodeType *link;
};
void createList(nodeType*& first, nodeType*& last);
void printList(nodeType*& first);
void insertFront(nodeType*& first);
void insertBack(nodeType*& last);
void deleteFirst(nodeType*& first);
void deleteLast(nodeType*& last, nodeType* first);
//method to split the list
/**
* first---> start of main list
* last ----> last of main list
* first1---> start of new list after list
* last1 ----> last of new listafter list
* item ---> item at which we have to split
*/
void breakList(nodeType*& first, nodeType*& last,nodeType*& first1, nodeType*&
last1,nodeType*item);
int main()
{
nodeType *first, *last;
//First,Last for 2nd list after divide
nodeType *first1, *last1;
int num;
createList(first, last);
int choice;
while(true)
{
cout<<"1. Insert Front. 2. Insert Last. 3. Delete Front. 4. Delete Last. 5. Print List. 6. Divide
7. Exit. ";
cout<<"Enter your choice: ";
cin>>choice;
switch(choice)
{
case 1: insertFront(first); break;
case 2: insertBack(last); break;
case 3: deleteFirst(first); break;
case 4: deleteLast(last, first); break;
case 5: printList(first); break;
//case 6 , Divide
case 6:{
int index;
//Ask user item at which we need to divide
cout<<"Enter your index: ";
cin>>index;
//Go to item at given index , and then split
int i = 0;
nodeType *current = NULL;
current = first;
while (current != NULL)
{
current = current->link;
i++;
if(i == index){
break;
}
}
breakList(first,last,first1,last1,current);
}
break;
case 7: return 0;
default: cout<<"Invalid menu option. Try again."<>number;
while (number != -999)
{
newNode = new nodeType; // create new node
newNode->info = number;
newNode->link = NULL;
if (first == NULL)
{
first = newNode;
last = newNode;
}
else
{
last->link = newNode;
last = newNode;
}
cout<<"Enter an integer (-999 to stop): ";
cin>>number;
} // end of while-loop
} // end of build list function
void deleteFirst(nodeType*& first)
{
nodeType *temp;
temp= first;
first= temp->link;
delete temp;
return;
}
void deleteLast(nodeType*& last, nodeType* current)
{
nodeType *temp;
while(current->link != NULL)
{
temp=current;
current=current->link;
}
temp=last;
current->link=NULL;
delete temp;
last = current;
return;
}
void insertFront(nodeType*& front)
{
int num;
cout<<" Enter the number to insert: ";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= front;
front= newNode;
return;
}
void insertBack(nodeType*& last)
{
int num;
cout<<" Enter the number to insert: ";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= NULL;
last->link= newNode;
last = newNode;
return;
}
void printList(nodeType*& first)
{
cout<<"Inside printList...printing linked list... "<info << " ";
current = current->link;
}
cout<link == item){
found = true;
break;
}
current = current->link;
}
//If item found
if(found){
//set first of new list
first1 = current->link;
//set last of new list
last1= last;
//set last of new list
last = current;
//close old list after current item
last->link = NULL;
}
}
Ad

More Related Content

Similar to Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf (20)

Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
adityastores21
 
Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdf
nitinarora01
 
TutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdfTutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdf
BappyAgarwal
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
saradashata
 
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
stopgolook
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdf
aaseletronics2013
 
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdf
aashisha5
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
feelinggift
 
Implement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfImplement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdf
arihantstoneart
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
thangarajarivukadal
 
Link List Programming Linked List in Cpp
Link List Programming Linked List in CppLink List Programming Linked List in Cpp
Link List Programming Linked List in Cpp
Anil Yadav
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
Conint29
 
C++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docxC++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docx
MatthPYNashd
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
aathmaproducts
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
aathiauto
 
Write the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docxWrite the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docx
delicecogupdyke
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
Programming Homework Help
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
ARCHANASTOREKOTA
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
adityastores21
 
Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdf
nitinarora01
 
TutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdfTutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdf
BappyAgarwal
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
saradashata
 
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
stopgolook
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdf
aaseletronics2013
 
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdf
aashisha5
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
feelinggift
 
Implement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfImplement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdf
arihantstoneart
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
thangarajarivukadal
 
Link List Programming Linked List in Cpp
Link List Programming Linked List in CppLink List Programming Linked List in Cpp
Link List Programming Linked List in Cpp
Anil Yadav
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
Conint29
 
C++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docxC++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docx
MatthPYNashd
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
aathmaproducts
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
aathiauto
 
Write the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docxWrite the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docx
delicecogupdyke
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
ARCHANASTOREKOTA
 

More from formicreation (20)

Many people believe that, because the emergence of life was very impr.pdf
Many people believe that, because the emergence of life was very impr.pdfMany people believe that, because the emergence of life was very impr.pdf
Many people believe that, because the emergence of life was very impr.pdf
formicreation
 
Know the different types of viruses which have a dsRNA genome A type .pdf
Know the different types of viruses which have a dsRNA genome A type .pdfKnow the different types of viruses which have a dsRNA genome A type .pdf
Know the different types of viruses which have a dsRNA genome A type .pdf
formicreation
 
Issued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdf
Issued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdfIssued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdf
Issued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdf
formicreation
 
IPv4 provided the primary addressing scheme in TCPIP. However after.pdf
IPv4 provided the primary addressing scheme in TCPIP. However after.pdfIPv4 provided the primary addressing scheme in TCPIP. However after.pdf
IPv4 provided the primary addressing scheme in TCPIP. However after.pdf
formicreation
 
Implement the member function void insertAfterHead(int d) of the Lin.pdf
Implement the member function void insertAfterHead(int d) of the Lin.pdfImplement the member function void insertAfterHead(int d) of the Lin.pdf
Implement the member function void insertAfterHead(int d) of the Lin.pdf
formicreation
 
I am trying to create a program that will create Objects of differen.pdf
I am trying to create a program that will create Objects of differen.pdfI am trying to create a program that will create Objects of differen.pdf
I am trying to create a program that will create Objects of differen.pdf
formicreation
 
How does Ansoffs matrix impact organizations missionsSoluti.pdf
How does Ansoffs matrix impact organizations missionsSoluti.pdfHow does Ansoffs matrix impact organizations missionsSoluti.pdf
How does Ansoffs matrix impact organizations missionsSoluti.pdf
formicreation
 
How is a chorioallantoic placenta different from a choriovitelline.pdf
How is a chorioallantoic placenta different from a choriovitelline.pdfHow is a chorioallantoic placenta different from a choriovitelline.pdf
How is a chorioallantoic placenta different from a choriovitelline.pdf
formicreation
 
How can I tell when it is going to be a Archimedean Spiral. What is .pdf
How can I tell when it is going to be a Archimedean Spiral. What is .pdfHow can I tell when it is going to be a Archimedean Spiral. What is .pdf
How can I tell when it is going to be a Archimedean Spiral. What is .pdf
formicreation
 
flow chart or step by step process of the key steps in forming a uni.pdf
flow chart or step by step process of the key steps in forming a uni.pdfflow chart or step by step process of the key steps in forming a uni.pdf
flow chart or step by step process of the key steps in forming a uni.pdf
formicreation
 
Description For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdfDescription For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdf
formicreation
 
Discuss one (1) traditional and two (2) new strategies that special i.pdf
Discuss one (1) traditional and two (2) new strategies that special i.pdfDiscuss one (1) traditional and two (2) new strategies that special i.pdf
Discuss one (1) traditional and two (2) new strategies that special i.pdf
formicreation
 
Define health systems and healthcare delivery systems and discuss th.pdf
Define health systems and healthcare delivery systems and discuss th.pdfDefine health systems and healthcare delivery systems and discuss th.pdf
Define health systems and healthcare delivery systems and discuss th.pdf
formicreation
 
B. You do an experiment in which you divide 8 cell stage urch.pdf
B. You do an experiment in which you divide 8 cell stage urch.pdfB. You do an experiment in which you divide 8 cell stage urch.pdf
B. You do an experiment in which you divide 8 cell stage urch.pdf
formicreation
 
a. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdf
a. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdfa. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdf
a. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdf
formicreation
 
An electron is moving in a circular motion clockwise. A uniform magne.pdf
An electron is moving in a circular motion clockwise. A uniform magne.pdfAn electron is moving in a circular motion clockwise. A uniform magne.pdf
An electron is moving in a circular motion clockwise. A uniform magne.pdf
formicreation
 
After reading Thomas Malthus population theory and the ideas of Ju.pdf
After reading Thomas Malthus population theory and the ideas of Ju.pdfAfter reading Thomas Malthus population theory and the ideas of Ju.pdf
After reading Thomas Malthus population theory and the ideas of Ju.pdf
formicreation
 
Any ideas on an IT topic I could use for this case studyFor this .pdf
Any ideas on an IT topic I could use for this case studyFor this .pdfAny ideas on an IT topic I could use for this case studyFor this .pdf
Any ideas on an IT topic I could use for this case studyFor this .pdf
formicreation
 
C++ Write a function that takes a number as a parameter and display.pdf
C++ Write a function that takes a number as a parameter and display.pdfC++ Write a function that takes a number as a parameter and display.pdf
C++ Write a function that takes a number as a parameter and display.pdf
formicreation
 
Why is it important for marketers to understand the product life cyc.pdf
Why is it important for marketers to understand the product life cyc.pdfWhy is it important for marketers to understand the product life cyc.pdf
Why is it important for marketers to understand the product life cyc.pdf
formicreation
 
Many people believe that, because the emergence of life was very impr.pdf
Many people believe that, because the emergence of life was very impr.pdfMany people believe that, because the emergence of life was very impr.pdf
Many people believe that, because the emergence of life was very impr.pdf
formicreation
 
Know the different types of viruses which have a dsRNA genome A type .pdf
Know the different types of viruses which have a dsRNA genome A type .pdfKnow the different types of viruses which have a dsRNA genome A type .pdf
Know the different types of viruses which have a dsRNA genome A type .pdf
formicreation
 
Issued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdf
Issued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdfIssued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdf
Issued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdf
formicreation
 
IPv4 provided the primary addressing scheme in TCPIP. However after.pdf
IPv4 provided the primary addressing scheme in TCPIP. However after.pdfIPv4 provided the primary addressing scheme in TCPIP. However after.pdf
IPv4 provided the primary addressing scheme in TCPIP. However after.pdf
formicreation
 
Implement the member function void insertAfterHead(int d) of the Lin.pdf
Implement the member function void insertAfterHead(int d) of the Lin.pdfImplement the member function void insertAfterHead(int d) of the Lin.pdf
Implement the member function void insertAfterHead(int d) of the Lin.pdf
formicreation
 
I am trying to create a program that will create Objects of differen.pdf
I am trying to create a program that will create Objects of differen.pdfI am trying to create a program that will create Objects of differen.pdf
I am trying to create a program that will create Objects of differen.pdf
formicreation
 
How does Ansoffs matrix impact organizations missionsSoluti.pdf
How does Ansoffs matrix impact organizations missionsSoluti.pdfHow does Ansoffs matrix impact organizations missionsSoluti.pdf
How does Ansoffs matrix impact organizations missionsSoluti.pdf
formicreation
 
How is a chorioallantoic placenta different from a choriovitelline.pdf
How is a chorioallantoic placenta different from a choriovitelline.pdfHow is a chorioallantoic placenta different from a choriovitelline.pdf
How is a chorioallantoic placenta different from a choriovitelline.pdf
formicreation
 
How can I tell when it is going to be a Archimedean Spiral. What is .pdf
How can I tell when it is going to be a Archimedean Spiral. What is .pdfHow can I tell when it is going to be a Archimedean Spiral. What is .pdf
How can I tell when it is going to be a Archimedean Spiral. What is .pdf
formicreation
 
flow chart or step by step process of the key steps in forming a uni.pdf
flow chart or step by step process of the key steps in forming a uni.pdfflow chart or step by step process of the key steps in forming a uni.pdf
flow chart or step by step process of the key steps in forming a uni.pdf
formicreation
 
Description For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdfDescription For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdf
formicreation
 
Discuss one (1) traditional and two (2) new strategies that special i.pdf
Discuss one (1) traditional and two (2) new strategies that special i.pdfDiscuss one (1) traditional and two (2) new strategies that special i.pdf
Discuss one (1) traditional and two (2) new strategies that special i.pdf
formicreation
 
Define health systems and healthcare delivery systems and discuss th.pdf
Define health systems and healthcare delivery systems and discuss th.pdfDefine health systems and healthcare delivery systems and discuss th.pdf
Define health systems and healthcare delivery systems and discuss th.pdf
formicreation
 
B. You do an experiment in which you divide 8 cell stage urch.pdf
B. You do an experiment in which you divide 8 cell stage urch.pdfB. You do an experiment in which you divide 8 cell stage urch.pdf
B. You do an experiment in which you divide 8 cell stage urch.pdf
formicreation
 
a. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdf
a. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdfa. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdf
a. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdf
formicreation
 
An electron is moving in a circular motion clockwise. A uniform magne.pdf
An electron is moving in a circular motion clockwise. A uniform magne.pdfAn electron is moving in a circular motion clockwise. A uniform magne.pdf
An electron is moving in a circular motion clockwise. A uniform magne.pdf
formicreation
 
After reading Thomas Malthus population theory and the ideas of Ju.pdf
After reading Thomas Malthus population theory and the ideas of Ju.pdfAfter reading Thomas Malthus population theory and the ideas of Ju.pdf
After reading Thomas Malthus population theory and the ideas of Ju.pdf
formicreation
 
Any ideas on an IT topic I could use for this case studyFor this .pdf
Any ideas on an IT topic I could use for this case studyFor this .pdfAny ideas on an IT topic I could use for this case studyFor this .pdf
Any ideas on an IT topic I could use for this case studyFor this .pdf
formicreation
 
C++ Write a function that takes a number as a parameter and display.pdf
C++ Write a function that takes a number as a parameter and display.pdfC++ Write a function that takes a number as a parameter and display.pdf
C++ Write a function that takes a number as a parameter and display.pdf
formicreation
 
Why is it important for marketers to understand the product life cyc.pdf
Why is it important for marketers to understand the product life cyc.pdfWhy is it important for marketers to understand the product life cyc.pdf
Why is it important for marketers to understand the product life cyc.pdf
formicreation
 
Ad

Recently uploaded (20)

K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Ad

Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf

  • 1. Assignment is : "Page 349-350 #4 and #5 Use the "Linked List lab" you have been working on in class and add the two functions the questions are asking you to develop: divideMid and divideAt. Be sure to include comments Use meaningful identifier names (constants where appropriate) Do not work together; no two people should have identical work!?!? Turn in .cpp file AND Turn in a "print- screen' of your output (press "print-screen' on keyboard, then 'paste' in MS-Word)" How do you solve QUESTION #5 in the book data structures using c++ by D.S. Malik in Visiual Studios using the linked list below with what is being asked? Please need help Linked list : #include #include using namespace std; struct nodeType { int info; nodeType *link; }; void createList(nodeType*& first, nodeType*& last); void printList(nodeType*& first); void insertFront(nodeType*& first);
  • 2. void insertBack(nodeType*& last); void deleteFirst(nodeType*& first); void deleteLast(nodeType*& last, nodeType* first); int main() { nodeType *first, *last; int num; createList(first, last); int choice; while(true) { cout<<"1. Insert Front. 2. Insert Last. 3. Delete Front. 4. Delete Last. 5. Print List. 6. Exit. "; cout<<"Enter your choice: "; cin>>choice; switch(choice) { case 1: insertFront(first); break; case 2: insertBack(last); break; case 3: deleteFirst(first); break; case 4: deleteLast(last, first); break; case 5: printList(first); break; case 6: return 0; default: cout<<"Invalid menu option. Try again."<>number; while (number != -999) { newNode = new nodeType; // create new node newNode->info = number;
  • 3. newNode->link = NULL; if (first == NULL) { first = newNode; last = newNode; } else { last->link = newNode; last = newNode; } cout<<"Enter an integer (-999 to stop): "; cin>>number; } // end of while-loop } // end of build list function void deleteFirst(nodeType*& first) { nodeType *temp;
  • 4. temp= first; first= temp->link; delete temp; return; } void deleteLast(nodeType*& last, nodeType* current) { nodeType *temp; while(current->link != NULL) { temp=current; current=current->link; } temp=last; current->link=NULL; delete temp; last = current; return; } void insertFront(nodeType*& front) { int num; cout<<" Enter the number to insert: "; cin>>num; nodeType *newNode = new nodeType; newNode->info=num; newNode->link= front; front= newNode; return; }
  • 5. void insertBack(nodeType*& last) { int num; cout<<" Enter the number to insert: "; cin>>num; nodeType *newNode = new nodeType; newNode->info=num; newNode->link= NULL; last->link= newNode; last = newNode; return; } void printList(nodeType*& first) { cout<<"Inside printList...printing linked list... "<info << " "; current = current->link; } cout< #include using namespace std; struct nodeType { int info; nodeType *link; }; void createList(nodeType*& first, nodeType*& last); void printList(nodeType*& first); void insertFront(nodeType*& first); void insertBack(nodeType*& last); void deleteFirst(nodeType*& first);
  • 6. void deleteLast(nodeType*& last, nodeType* first); int main() { nodeType *first, *last; int num; createList(first, last); int choice; while(true) { cout<<"1. Insert Front. 2. Insert Last. 3. Delete Front. 4. Delete Last. 5. Print List. 6. Exit. "; cout<<"Enter your choice: "; cin>>choice; switch(choice) { case 1: insertFront(first); break; case 2: insertBack(last); break; case 3: deleteFirst(first); break; case 4: deleteLast(last, first); break; case 5: printList(first); break; case 6: return 0; default: cout<<"Invalid menu option. Try again."<>number; while (number != -999) { newNode = new nodeType; // create new node newNode->info = number; newNode->link = NULL;
  • 7. if (first == NULL) { first = newNode; last = newNode; } else { last->link = newNode; last = newNode; } cout<<"Enter an integer (-999 to stop): "; cin>>number; } // end of while-loop } // end of build list function void deleteFirst(nodeType*& first) { nodeType *temp; temp= first; first= temp->link;
  • 8. delete temp; return; } void deleteLast(nodeType*& last, nodeType* current) { nodeType *temp; while(current->link != NULL) { temp=current; current=current->link; } temp=last; current->link=NULL; delete temp; last = current; return; } void insertFront(nodeType*& front) { int num; cout<<" Enter the number to insert: "; cin>>num; nodeType *newNode = new nodeType; newNode->info=num; newNode->link= front; front= newNode; return; } void insertBack(nodeType*& last) {
  • 9. int num; cout<<" Enter the number to insert: "; cin>>num; nodeType *newNode = new nodeType; newNode->info=num; newNode->link= NULL; last->link= newNode; last = newNode; return; } void printList(nodeType*& first) { cout<<"Inside printList...printing linked list... "<info << " "; current = current->link; } cout< otherList; Suppose myList points to the list with the elements: 34 65 18 39 27 89 12 (in this order). The statement: myList divideAt (otherList, 18) divides myList into two sublists: myList points to the list with the elements 34 65, and otherList points to the sublist with the elements 39 27 89 12. 6. b. Write the definition of the function to implement the tion divide template a. Add o write a program to test your function. the following operation to the class dered inkedli st opera- Solution Explanation :- ---------------------------- 1.Take nodeType *first1, *last1; First and last for the divided list 2. Add Choice "6" for Divide 3.When user enter choice Ask index where to break the list
  • 10. When user enters the index , then break the list there 3) After User enters the index of item where to break the list First find the item at the index 4)Check the method /** * first---> start of main list * last ----> last of main list * first1---> start of new list after list * last1 ----> last of new listafter list * item ---> item at which we have to split */ void breakList(nodeType*& first, nodeType*& last,nodeType*& first1, nodeType*& last1,nodeType*item); 5)To break the list at middle , just give the middle index Programme :- ---------------------------- #include #include using namespace std; struct nodeType { int info; nodeType *link; }; void createList(nodeType*& first, nodeType*& last); void printList(nodeType*& first); void insertFront(nodeType*& first); void insertBack(nodeType*& last); void deleteFirst(nodeType*& first); void deleteLast(nodeType*& last, nodeType* first); //method to split the list /** * first---> start of main list * last ----> last of main list * first1---> start of new list after list * last1 ----> last of new listafter list
  • 11. * item ---> item at which we have to split */ void breakList(nodeType*& first, nodeType*& last,nodeType*& first1, nodeType*& last1,nodeType*item); int main() { nodeType *first, *last; //First,Last for 2nd list after divide nodeType *first1, *last1; int num; createList(first, last); int choice; while(true) { cout<<"1. Insert Front. 2. Insert Last. 3. Delete Front. 4. Delete Last. 5. Print List. 6. Divide 7. Exit. "; cout<<"Enter your choice: "; cin>>choice; switch(choice) { case 1: insertFront(first); break; case 2: insertBack(last); break; case 3: deleteFirst(first); break; case 4: deleteLast(last, first); break; case 5: printList(first); break; //case 6 , Divide case 6:{ int index; //Ask user item at which we need to divide cout<<"Enter your index: "; cin>>index; //Go to item at given index , and then split int i = 0; nodeType *current = NULL; current = first; while (current != NULL)
  • 12. { current = current->link; i++; if(i == index){ break; } } breakList(first,last,first1,last1,current); } break; case 7: return 0; default: cout<<"Invalid menu option. Try again."<>number; while (number != -999) { newNode = new nodeType; // create new node newNode->info = number; newNode->link = NULL; if (first == NULL) { first = newNode; last = newNode; } else { last->link = newNode; last = newNode; } cout<<"Enter an integer (-999 to stop): "; cin>>number; } // end of while-loop } // end of build list function void deleteFirst(nodeType*& first) { nodeType *temp; temp= first; first= temp->link;
  • 13. delete temp; return; } void deleteLast(nodeType*& last, nodeType* current) { nodeType *temp; while(current->link != NULL) { temp=current; current=current->link; } temp=last; current->link=NULL; delete temp; last = current; return; } void insertFront(nodeType*& front) { int num; cout<<" Enter the number to insert: "; cin>>num; nodeType *newNode = new nodeType; newNode->info=num; newNode->link= front; front= newNode; return; } void insertBack(nodeType*& last) { int num; cout<<" Enter the number to insert: "; cin>>num; nodeType *newNode = new nodeType; newNode->info=num; newNode->link= NULL;
  • 14. last->link= newNode; last = newNode; return; } void printList(nodeType*& first) { cout<<"Inside printList...printing linked list... "<info << " "; current = current->link; } cout<link == item){ found = true; break; } current = current->link; } //If item found if(found){ //set first of new list first1 = current->link; //set last of new list last1= last; //set last of new list last = current; //close old list after current item last->link = NULL; } }