SlideShare a Scribd company logo
1 of 3
Download to read offline
template <class T>
struct nodeType
{
T data;
nodeType *next;
};
template <class T>
class LinkedList {
nodeType<T> *head, *tail;
int count;
public:
LinkedList();
void insertFirst(T item);
void insertLast(T item);
void insertAt(T item, int pos);
void print();
bool simplecompare(LinkedList<T> &rL)
{
if (count != rL.count)
return false;
nodeType<T> *cur, *rCur;
for (cur = head, rCur = rL.head; cur != NULL; cur = cur->next, rCur = rCur->next)
if (cur->data != rCur->data)
return false;
return true;
}
int compare(LinkedList<T> &rL);
~LinkedList();
};
//driver program:
int main(void)
{
char item;
LinkedList<char> list1, list2;
cout << "Please enter the first list of characters"
<< "nPress Ctrl+Z to stop entering." << endl;
cin >> item;
while (!cin.eof()) {
list1.insertLast(item);
cin >> item;
}
cin.clear();
cout << "Please enter the second list of characters"
<< "nPress Ctrl+Z to stop entering." << endl;
cin >> item;
while (!cin.eof()) {
list2.insertLast(item);
cin >> item;
}
list1.print();
list2.print();
int result = list1.compare(list2);
if (result == 0)
cout << "The lists are same!n";
else if (result == -1)
cout << "first list < second listn" << endl;
else cout << "first list > second listn" << endl;
return 0;
}
1 Questions A simplified doublyLinkedList class is provided in lab03doublyLinkedList_template.h
file on CATS. Solve the following questions by using that elass. 1. The definition of insertFirst(T
item) function is missing. Complete it. 2. The definition of insertLast(T item) function is missing.
Complete it. 3. The definition of insertAt(T item, int order) function is missing. Complete it. 4.
Update print() function to print the list in forward direction. 5. The definition of deleteItem(T item)
function is missing. Complete it. 6. Add an extractMax(T max) function to the doublyLinkedList
class. The function must extract all nodes containing elements less than max from the list, and
construct a new list using those nodes. After the function call, the original list must only have the
nodes whose data fields are greater than max, while the new list is containing the smaller ones.
The new list must be returned by the function. You're not allowed to delete and/or create new
nodes. Your function must just move the subjected nodes from one list to the other. Let the
following list be the original list: If the function is called as newList = myList.extractMax (30), then
the newList becomes: 2 Assignment Implement a class to represent a circular linked list. You can
directly adapt SinglyLinkedList class that we've already defined in linkedList.h. Only the following
member functions will be defined for the class: - default constructor to set the pointer data
members to NULL and count to 0 . - insertItem to insert a given item to the list. - deleteItem to
remove a specific item from the list. Item may occur multiple times, thus the function must remove
every occurrences of the item from the list. 1 - print to print the linked list from head to tail. -
destructor to destroy the list.- print to print the linked list from head to tail. - destructor to destroy
the list. Use your circular linked list to solve hot potato game, which is a modern-day equivalent of
Josephus problem (See wiki). It is set as a game as follows: N people, numbered 1 to N, are
sitting in a circle. Starting at person 1, a hot potato is passed. After M passes, the person holding
the hot potato is eliminated, the circle closes ranks, and the game continues with the person who
was sitting after the eliminated person picking up the hot potato. The last remaining person wins.
Thus, if M=0 and N=5, players are eliminated in order, and player 5 wins. If M=1 and N=5, thee
order of elimination is 2, 4, 1, 5 . Write a non-member function with the following prototype: int
JosephusSolver (CircularLinkedList int >& players, int m ) ; to solve the Josephus problem for
general values of M and N. Try to make your program as efficient as possible. Make sure you
dispose of cells. What is the running time of your program?

More Related Content

Similar to template ltclass Tgt struct nodeType T data n.pdf

Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfMCCMOTOR
 
Data structures: linear lists
Data structures: linear listsData structures: linear lists
Data structures: linear listsToniyaP1
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfeyewaregallery
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfformicreation
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.pptWaf1231
 
The basics and design of lua table
The basics and design of lua tableThe basics and design of lua table
The basics and design of lua tableShuai Yuan
 
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.pdfaathiauto
 
Programming in Coday we are working with singly linked lists. Las.pdf
Programming in Coday we are working with singly linked lists. Las.pdfProgramming in Coday we are working with singly linked lists. Las.pdf
Programming in Coday we are working with singly linked lists. Las.pdfPRATIKSINHA7304
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfvishalateen
 
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.pdfaathmaproducts
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
 
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.pdfaashisha5
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfpoblettesedanoree498
 

Similar to template ltclass Tgt struct nodeType T data n.pdf (20)

Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdf
 
Data structures: linear lists
Data structures: linear listsData structures: linear lists
Data structures: linear lists
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.ppt
 
List
ListList
List
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
 
The basics and design of lua table
The basics and design of lua tableThe basics and design of lua table
The basics and design of lua table
 
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
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
 
Programming in Coday we are working with singly linked lists. Las.pdf
Programming in Coday we are working with singly linked lists. Las.pdfProgramming in Coday we are working with singly linked lists. Las.pdf
Programming in Coday we are working with singly linked lists. Las.pdf
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
 
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
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
 
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
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
 
Ds notes
Ds notesDs notes
Ds notes
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
Algo>ADT list & linked list
Algo>ADT list & linked listAlgo>ADT list & linked list
Algo>ADT list & linked list
 

More from aceautomate

thanks Let the random variable Z follow a standard normal d.pdf
thanks  Let the random variable Z follow a standard normal d.pdfthanks  Let the random variable Z follow a standard normal d.pdf
thanks Let the random variable Z follow a standard normal d.pdfaceautomate
 
Which of the following is generally regarded by academics as.pdf
Which of the following is generally regarded by academics as.pdfWhich of the following is generally regarded by academics as.pdf
Which of the following is generally regarded by academics as.pdfaceautomate
 
What does the command GetPSDrive do Writes the names of .pdf
What does the command GetPSDrive do   Writes the names of .pdfWhat does the command GetPSDrive do   Writes the names of .pdf
What does the command GetPSDrive do Writes the names of .pdfaceautomate
 
US Says China is No Longer a Currency Manipulator Chinas .pdf
US Says China is No Longer a Currency Manipulator Chinas .pdfUS Says China is No Longer a Currency Manipulator Chinas .pdf
US Says China is No Longer a Currency Manipulator Chinas .pdfaceautomate
 
Use the information below for the next four 4 questions T.pdf
Use the information below for the next four 4 questions T.pdfUse the information below for the next four 4 questions T.pdf
Use the information below for the next four 4 questions T.pdfaceautomate
 
THE Bankn finansal tablolar aada gsterilmitir Bilano T.pdf
THE Bankn finansal tablolar aada gsterilmitir   Bilano T.pdfTHE Bankn finansal tablolar aada gsterilmitir   Bilano T.pdf
THE Bankn finansal tablolar aada gsterilmitir Bilano T.pdfaceautomate
 
The following graph shows intraindustry trade in the United.pdf
The following graph shows intraindustry trade in the United.pdfThe following graph shows intraindustry trade in the United.pdf
The following graph shows intraindustry trade in the United.pdfaceautomate
 
Short explanations would be helpful One of the most diffi.pdf
Short explanations would be helpful  One of the most diffi.pdfShort explanations would be helpful  One of the most diffi.pdf
Short explanations would be helpful One of the most diffi.pdfaceautomate
 
Restaurateur Denny Valentine is evaluating two sites Raymon.pdf
Restaurateur Denny Valentine is evaluating two sites Raymon.pdfRestaurateur Denny Valentine is evaluating two sites Raymon.pdf
Restaurateur Denny Valentine is evaluating two sites Raymon.pdfaceautomate
 
Suppose the net tax function T is below Tt0+t1Y0ltt1.pdf
Suppose the net tax function T is below Tt0+t1Y0ltt1.pdfSuppose the net tax function T is below Tt0+t1Y0ltt1.pdf
Suppose the net tax function T is below Tt0+t1Y0ltt1.pdfaceautomate
 
Estudio de caso de Panera Bread Arturo A Thompson la univ.pdf
Estudio de caso de Panera Bread  Arturo A Thompson  la univ.pdfEstudio de caso de Panera Bread  Arturo A Thompson  la univ.pdf
Estudio de caso de Panera Bread Arturo A Thompson la univ.pdfaceautomate
 
Problem 42 Pro Forma Statements and EFN LO1 2 The co.pdf
Problem 42 Pro Forma Statements and EFN LO1 2     The co.pdfProblem 42 Pro Forma Statements and EFN LO1 2     The co.pdf
Problem 42 Pro Forma Statements and EFN LO1 2 The co.pdfaceautomate
 
Sandhill Company has a unit selling price of 500 unit vari.pdf
Sandhill Company has a unit selling price of 500 unit vari.pdfSandhill Company has a unit selling price of 500 unit vari.pdf
Sandhill Company has a unit selling price of 500 unit vari.pdfaceautomate
 
rnek Olay 14 Safaricom Aadaki durumla ilgili olarak ders.pdf
rnek Olay 14  Safaricom Aadaki durumla ilgili olarak ders.pdfrnek Olay 14  Safaricom Aadaki durumla ilgili olarak ders.pdf
rnek Olay 14 Safaricom Aadaki durumla ilgili olarak ders.pdfaceautomate
 
Pregunta 11 Uno de los grupos ms importantes de partes int.pdf
Pregunta 11  Uno de los grupos ms importantes de partes int.pdfPregunta 11  Uno de los grupos ms importantes de partes int.pdf
Pregunta 11 Uno de los grupos ms importantes de partes int.pdfaceautomate
 
Monty Inc uses a calendar year for financial reporting The.pdf
Monty Inc uses a calendar year for financial reporting The.pdfMonty Inc uses a calendar year for financial reporting The.pdf
Monty Inc uses a calendar year for financial reporting The.pdfaceautomate
 
Inbreeding depression Was an unusual evolutionary event.pdf
Inbreeding depression Was an unusual evolutionary event.pdfInbreeding depression Was an unusual evolutionary event.pdf
Inbreeding depression Was an unusual evolutionary event.pdfaceautomate
 
Human resource Management Labour And relations Demands and.pdf
Human resource Management  Labour And relations Demands and.pdfHuman resource Management  Labour And relations Demands and.pdf
Human resource Management Labour And relations Demands and.pdfaceautomate
 
I dont know the 7 and the 8 please help Let the random var.pdf
I dont know the 7 and the 8 please help  Let the random var.pdfI dont know the 7 and the 8 please help  Let the random var.pdf
I dont know the 7 and the 8 please help Let the random var.pdfaceautomate
 
GASE SCENARIO Colene Fletcher is excited Her excitement ste.pdf
GASE SCENARIO Colene Fletcher is excited Her excitement ste.pdfGASE SCENARIO Colene Fletcher is excited Her excitement ste.pdf
GASE SCENARIO Colene Fletcher is excited Her excitement ste.pdfaceautomate
 

More from aceautomate (20)

thanks Let the random variable Z follow a standard normal d.pdf
thanks  Let the random variable Z follow a standard normal d.pdfthanks  Let the random variable Z follow a standard normal d.pdf
thanks Let the random variable Z follow a standard normal d.pdf
 
Which of the following is generally regarded by academics as.pdf
Which of the following is generally regarded by academics as.pdfWhich of the following is generally regarded by academics as.pdf
Which of the following is generally regarded by academics as.pdf
 
What does the command GetPSDrive do Writes the names of .pdf
What does the command GetPSDrive do   Writes the names of .pdfWhat does the command GetPSDrive do   Writes the names of .pdf
What does the command GetPSDrive do Writes the names of .pdf
 
US Says China is No Longer a Currency Manipulator Chinas .pdf
US Says China is No Longer a Currency Manipulator Chinas .pdfUS Says China is No Longer a Currency Manipulator Chinas .pdf
US Says China is No Longer a Currency Manipulator Chinas .pdf
 
Use the information below for the next four 4 questions T.pdf
Use the information below for the next four 4 questions T.pdfUse the information below for the next four 4 questions T.pdf
Use the information below for the next four 4 questions T.pdf
 
THE Bankn finansal tablolar aada gsterilmitir Bilano T.pdf
THE Bankn finansal tablolar aada gsterilmitir   Bilano T.pdfTHE Bankn finansal tablolar aada gsterilmitir   Bilano T.pdf
THE Bankn finansal tablolar aada gsterilmitir Bilano T.pdf
 
The following graph shows intraindustry trade in the United.pdf
The following graph shows intraindustry trade in the United.pdfThe following graph shows intraindustry trade in the United.pdf
The following graph shows intraindustry trade in the United.pdf
 
Short explanations would be helpful One of the most diffi.pdf
Short explanations would be helpful  One of the most diffi.pdfShort explanations would be helpful  One of the most diffi.pdf
Short explanations would be helpful One of the most diffi.pdf
 
Restaurateur Denny Valentine is evaluating two sites Raymon.pdf
Restaurateur Denny Valentine is evaluating two sites Raymon.pdfRestaurateur Denny Valentine is evaluating two sites Raymon.pdf
Restaurateur Denny Valentine is evaluating two sites Raymon.pdf
 
Suppose the net tax function T is below Tt0+t1Y0ltt1.pdf
Suppose the net tax function T is below Tt0+t1Y0ltt1.pdfSuppose the net tax function T is below Tt0+t1Y0ltt1.pdf
Suppose the net tax function T is below Tt0+t1Y0ltt1.pdf
 
Estudio de caso de Panera Bread Arturo A Thompson la univ.pdf
Estudio de caso de Panera Bread  Arturo A Thompson  la univ.pdfEstudio de caso de Panera Bread  Arturo A Thompson  la univ.pdf
Estudio de caso de Panera Bread Arturo A Thompson la univ.pdf
 
Problem 42 Pro Forma Statements and EFN LO1 2 The co.pdf
Problem 42 Pro Forma Statements and EFN LO1 2     The co.pdfProblem 42 Pro Forma Statements and EFN LO1 2     The co.pdf
Problem 42 Pro Forma Statements and EFN LO1 2 The co.pdf
 
Sandhill Company has a unit selling price of 500 unit vari.pdf
Sandhill Company has a unit selling price of 500 unit vari.pdfSandhill Company has a unit selling price of 500 unit vari.pdf
Sandhill Company has a unit selling price of 500 unit vari.pdf
 
rnek Olay 14 Safaricom Aadaki durumla ilgili olarak ders.pdf
rnek Olay 14  Safaricom Aadaki durumla ilgili olarak ders.pdfrnek Olay 14  Safaricom Aadaki durumla ilgili olarak ders.pdf
rnek Olay 14 Safaricom Aadaki durumla ilgili olarak ders.pdf
 
Pregunta 11 Uno de los grupos ms importantes de partes int.pdf
Pregunta 11  Uno de los grupos ms importantes de partes int.pdfPregunta 11  Uno de los grupos ms importantes de partes int.pdf
Pregunta 11 Uno de los grupos ms importantes de partes int.pdf
 
Monty Inc uses a calendar year for financial reporting The.pdf
Monty Inc uses a calendar year for financial reporting The.pdfMonty Inc uses a calendar year for financial reporting The.pdf
Monty Inc uses a calendar year for financial reporting The.pdf
 
Inbreeding depression Was an unusual evolutionary event.pdf
Inbreeding depression Was an unusual evolutionary event.pdfInbreeding depression Was an unusual evolutionary event.pdf
Inbreeding depression Was an unusual evolutionary event.pdf
 
Human resource Management Labour And relations Demands and.pdf
Human resource Management  Labour And relations Demands and.pdfHuman resource Management  Labour And relations Demands and.pdf
Human resource Management Labour And relations Demands and.pdf
 
I dont know the 7 and the 8 please help Let the random var.pdf
I dont know the 7 and the 8 please help  Let the random var.pdfI dont know the 7 and the 8 please help  Let the random var.pdf
I dont know the 7 and the 8 please help Let the random var.pdf
 
GASE SCENARIO Colene Fletcher is excited Her excitement ste.pdf
GASE SCENARIO Colene Fletcher is excited Her excitement ste.pdfGASE SCENARIO Colene Fletcher is excited Her excitement ste.pdf
GASE SCENARIO Colene Fletcher is excited Her excitement ste.pdf
 

Recently uploaded

The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Recently uploaded (20)

The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

template ltclass Tgt struct nodeType T data n.pdf

  • 1. template <class T> struct nodeType { T data; nodeType *next; }; template <class T> class LinkedList { nodeType<T> *head, *tail; int count; public: LinkedList(); void insertFirst(T item); void insertLast(T item); void insertAt(T item, int pos); void print(); bool simplecompare(LinkedList<T> &rL) { if (count != rL.count) return false; nodeType<T> *cur, *rCur; for (cur = head, rCur = rL.head; cur != NULL; cur = cur->next, rCur = rCur->next) if (cur->data != rCur->data) return false; return true; } int compare(LinkedList<T> &rL); ~LinkedList(); }; //driver program: int main(void) { char item; LinkedList<char> list1, list2; cout << "Please enter the first list of characters" << "nPress Ctrl+Z to stop entering." << endl; cin >> item; while (!cin.eof()) { list1.insertLast(item); cin >> item; } cin.clear();
  • 2. cout << "Please enter the second list of characters" << "nPress Ctrl+Z to stop entering." << endl; cin >> item; while (!cin.eof()) { list2.insertLast(item); cin >> item; } list1.print(); list2.print(); int result = list1.compare(list2); if (result == 0) cout << "The lists are same!n"; else if (result == -1) cout << "first list < second listn" << endl; else cout << "first list > second listn" << endl; return 0; } 1 Questions A simplified doublyLinkedList class is provided in lab03doublyLinkedList_template.h file on CATS. Solve the following questions by using that elass. 1. The definition of insertFirst(T item) function is missing. Complete it. 2. The definition of insertLast(T item) function is missing. Complete it. 3. The definition of insertAt(T item, int order) function is missing. Complete it. 4. Update print() function to print the list in forward direction. 5. The definition of deleteItem(T item) function is missing. Complete it. 6. Add an extractMax(T max) function to the doublyLinkedList class. The function must extract all nodes containing elements less than max from the list, and construct a new list using those nodes. After the function call, the original list must only have the nodes whose data fields are greater than max, while the new list is containing the smaller ones. The new list must be returned by the function. You're not allowed to delete and/or create new nodes. Your function must just move the subjected nodes from one list to the other. Let the following list be the original list: If the function is called as newList = myList.extractMax (30), then the newList becomes: 2 Assignment Implement a class to represent a circular linked list. You can directly adapt SinglyLinkedList class that we've already defined in linkedList.h. Only the following member functions will be defined for the class: - default constructor to set the pointer data members to NULL and count to 0 . - insertItem to insert a given item to the list. - deleteItem to remove a specific item from the list. Item may occur multiple times, thus the function must remove every occurrences of the item from the list. 1 - print to print the linked list from head to tail. - destructor to destroy the list.- print to print the linked list from head to tail. - destructor to destroy the list. Use your circular linked list to solve hot potato game, which is a modern-day equivalent of Josephus problem (See wiki). It is set as a game as follows: N people, numbered 1 to N, are sitting in a circle. Starting at person 1, a hot potato is passed. After M passes, the person holding the hot potato is eliminated, the circle closes ranks, and the game continues with the person who was sitting after the eliminated person picking up the hot potato. The last remaining person wins. Thus, if M=0 and N=5, players are eliminated in order, and player 5 wins. If M=1 and N=5, thee
  • 3. order of elimination is 2, 4, 1, 5 . Write a non-member function with the following prototype: int JosephusSolver (CircularLinkedList int >& players, int m ) ; to solve the Josephus problem for general values of M and N. Try to make your program as efficient as possible. Make sure you dispose of cells. What is the running time of your program?