SlideShare a Scribd company logo
1 of 4
Download to read offline
#include
#include
using namespace std;
struct node { //Task 1
char val;
node *next;
};
void printList(node *head) { //Task 2
if (head == NULL) {
cout << "Empty list" << endl;
return;
}
node *temp = head;
int count = 0;
while(temp != NULL) {
cout << "Node " << count << ": " << temp ->val << endl;
count++;
temp = temp->next;
}
}
struct node *globalhead = NULL;
void deepCopy(node *head1, node *head2) { //Task 3
if (head1 == NULL) {
cout << "Empty list" << endl;
return;
}
node *temp = head1;
node *curr = NULL;
node *prev = NULL;
while(temp != NULL) {
curr = (struct node *)malloc(sizeof(struct node));
curr->val = temp->val;
if(prev==NULL){
head2 = curr;
globalhead = curr;
}else{
prev->next = curr;
}
prev = curr;
temp = temp->next;
}
}
int main() { //Task 4
// Example #1
node p00, p01, p02, p03, p10, p11, p12, p13;
// List 1: A B B B
p00.val = 'A'; p00.next = &p01;
p01.val = 'B'; p01.next = &p02;
p02.val = 'B'; p02.next = &p03;
p03.val = 'B'; p03.next = NULL;
p10.next = NULL;
cout<<"First List:"<
Solution
//Tested on Windos OS Dev c++
/*********************LinkedList.cpp********************/
#include
#include
using namespace std;
struct node { //Task 1
char val;
node *next;
};
void printList(node *head) { //Task 2
if (head == NULL) {
cout << "Empty list" << endl;
return;
}
node *temp = head;
int count = 0;
while(temp != NULL) {
cout << "Node " << count << ": " << temp ->val << endl;
count++;
temp = temp->next;
}
}
struct node *globalhead = NULL;
void deepCopy(node *head1, node **head2) { //Task 3
if (head1 == NULL) {
cout << "Empty list" << endl;
return;
}
node *temp = head1;
node *curr = NULL;
node *prev = NULL;
while(temp != NULL) {
curr = (struct node *)malloc(sizeof(struct node));
curr->val = temp->val;
curr->next = NULL;
if(*head2==NULL){
*head2=curr;
}else{
prev=*head2;
while(prev->next!=NULL){
prev=prev->next;
}
prev->next=curr;
}
temp = temp->next;
}
}
int main() { //Task 4
// Example #1
node p00, p01, p02, p03, p10, p11, p12, p13;
// List 1: A B B B
p00.val = 'A'; p00.next = &p01;
p01.val = 'B'; p01.next = &p02;
p02.val = 'B'; p02.next = &p03;
p03.val = 'B'; p03.next = NULL;
p10.next = NULL;
cout<<"First List:"<

More Related Content

Similar to #include iostream #includestdlib.h using namespace std;str.pdf

c++ Computational Complexity filling in the following three .pdf
c++ Computational Complexity filling in the  following three .pdfc++ Computational Complexity filling in the  following three .pdf
c++ Computational Complexity filling in the following three .pdfamitbagga0808
 
operating system linux,ubuntu,Mac#include iostream #include .pdf
operating system linux,ubuntu,Mac#include iostream #include .pdfoperating system linux,ubuntu,Mac#include iostream #include .pdf
operating system linux,ubuntu,Mac#include iostream #include .pdfaquacareser
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docxAdamq0DJonese
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfamitbagga0808
 
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdfConsider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdfbharatchawla141
 
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
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
Solution#includestdio.h#includeconio.h#includealloc.h.pdf
Solution#includestdio.h#includeconio.h#includealloc.h.pdfSolution#includestdio.h#includeconio.h#includealloc.h.pdf
Solution#includestdio.h#includeconio.h#includealloc.h.pdfpoddaranand1
 
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 .pdffathimahardwareelect
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureZarghamullahShah
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of listElavarasi K
 
#include stdafx.h #include iostream using namespace std;vo.docx
#include stdafx.h #include iostream using namespace std;vo.docx#include stdafx.h #include iostream using namespace std;vo.docx
#include stdafx.h #include iostream using namespace std;vo.docxajoy21
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdfKUNALHARCHANDANI1
 
C++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfC++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfarjunenterprises1978
 
Write a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfWrite a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfSANDEEPARIHANT
 
tested on eclipseDoublyLinkedList class.pdf
tested on eclipseDoublyLinkedList class.pdftested on eclipseDoublyLinkedList class.pdf
tested on eclipseDoublyLinkedList class.pdfshanki7
 

Similar to #include iostream #includestdlib.h using namespace std;str.pdf (20)

c++ Computational Complexity filling in the following three .pdf
c++ Computational Complexity filling in the  following three .pdfc++ Computational Complexity filling in the  following three .pdf
c++ Computational Complexity filling in the following three .pdf
 
Linked lists
Linked listsLinked lists
Linked lists
 
operating system linux,ubuntu,Mac#include iostream #include .pdf
operating system linux,ubuntu,Mac#include iostream #include .pdfoperating system linux,ubuntu,Mac#include iostream #include .pdf
operating system linux,ubuntu,Mac#include iostream #include .pdf
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdf
 
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdfConsider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.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
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
Linked lists
Linked listsLinked lists
Linked lists
 
Solution#includestdio.h#includeconio.h#includealloc.h.pdf
Solution#includestdio.h#includeconio.h#includealloc.h.pdfSolution#includestdio.h#includeconio.h#includealloc.h.pdf
Solution#includestdio.h#includeconio.h#includealloc.h.pdf
 
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
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structure
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
 
#include stdafx.h #include iostream using namespace std;vo.docx
#include stdafx.h #include iostream using namespace std;vo.docx#include stdafx.h #include iostream using namespace std;vo.docx
#include stdafx.h #include iostream using namespace std;vo.docx
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf
 
C++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfC++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdf
 
137 Lab-2.2.pdf
137 Lab-2.2.pdf137 Lab-2.2.pdf
137 Lab-2.2.pdf
 
Write a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfWrite a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdf
 
Lab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdfLab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdf
 
tested on eclipseDoublyLinkedList class.pdf
tested on eclipseDoublyLinkedList class.pdftested on eclipseDoublyLinkedList class.pdf
tested on eclipseDoublyLinkedList class.pdf
 

More from lakshmijewellery

Write a shell command to substitute the first Nick to John in report.pdf
Write a shell command to substitute the first Nick to John in report.pdfWrite a shell command to substitute the first Nick to John in report.pdf
Write a shell command to substitute the first Nick to John in report.pdflakshmijewellery
 
Why did the European empires in the Americas have such an enormously.pdf
Why did the European empires in the Americas have such an enormously.pdfWhy did the European empires in the Americas have such an enormously.pdf
Why did the European empires in the Americas have such an enormously.pdflakshmijewellery
 
What were the unintended consequences of the Cuban Missile Crisis.pdf
What were the unintended consequences of the Cuban Missile Crisis.pdfWhat were the unintended consequences of the Cuban Missile Crisis.pdf
What were the unintended consequences of the Cuban Missile Crisis.pdflakshmijewellery
 
What process occurs when bile is mixed with fats How does this proc.pdf
What process occurs when bile is mixed with fats How does this proc.pdfWhat process occurs when bile is mixed with fats How does this proc.pdf
What process occurs when bile is mixed with fats How does this proc.pdflakshmijewellery
 
What is OBDC , Is it a program and what is the difference between .pdf
What is OBDC , Is it a program  and what is the difference between .pdfWhat is OBDC , Is it a program  and what is the difference between .pdf
What is OBDC , Is it a program and what is the difference between .pdflakshmijewellery
 
This Capital includes O A. mineral resources. O B. the money in one.pdf
This Capital includes O A. mineral resources. O B. the money in one.pdfThis Capital includes O A. mineral resources. O B. the money in one.pdf
This Capital includes O A. mineral resources. O B. the money in one.pdflakshmijewellery
 
What are the essential characteristics of cloud computingSolutio.pdf
What are the essential characteristics of cloud computingSolutio.pdfWhat are the essential characteristics of cloud computingSolutio.pdf
What are the essential characteristics of cloud computingSolutio.pdflakshmijewellery
 
We live in a very complex and culturally diverse society. When we br.pdf
We live in a very complex and culturally diverse society. When we br.pdfWe live in a very complex and culturally diverse society. When we br.pdf
We live in a very complex and culturally diverse society. When we br.pdflakshmijewellery
 
What are the values of the following expressions, assuming that n is.pdf
What are the values of the following expressions, assuming that n is.pdfWhat are the values of the following expressions, assuming that n is.pdf
What are the values of the following expressions, assuming that n is.pdflakshmijewellery
 
True or FalseA budget variance is the difference between expected.pdf
True or FalseA budget variance is the difference between expected.pdfTrue or FalseA budget variance is the difference between expected.pdf
True or FalseA budget variance is the difference between expected.pdflakshmijewellery
 
This level of measurement includes continuous measures A. Nominal; .pdf
This level of measurement includes continuous measures A. Nominal; .pdfThis level of measurement includes continuous measures A. Nominal; .pdf
This level of measurement includes continuous measures A. Nominal; .pdflakshmijewellery
 
Throughout the middle ages European philosophers believed in…a sci.pdf
Throughout the middle ages European philosophers believed in…a sci.pdfThroughout the middle ages European philosophers believed in…a sci.pdf
Throughout the middle ages European philosophers believed in…a sci.pdflakshmijewellery
 
The term intangible assets is used in accounting to denotea. suc.pdf
The term intangible assets is used in accounting to denotea. suc.pdfThe term intangible assets is used in accounting to denotea. suc.pdf
The term intangible assets is used in accounting to denotea. suc.pdflakshmijewellery
 
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdfThe methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdflakshmijewellery
 
The lagging strand is replicated with a series of Okazaki fragments .pdf
The lagging strand is replicated with a series of Okazaki fragments .pdfThe lagging strand is replicated with a series of Okazaki fragments .pdf
The lagging strand is replicated with a series of Okazaki fragments .pdflakshmijewellery
 
The files etcpasswd and etcshadow can be manually edited. Why wo.pdf
The files etcpasswd and etcshadow can be manually edited. Why wo.pdfThe files etcpasswd and etcshadow can be manually edited. Why wo.pdf
The files etcpasswd and etcshadow can be manually edited. Why wo.pdflakshmijewellery
 
The dividends received deduction Must exceed the applicable percentag.pdf
The dividends received deduction Must exceed the applicable percentag.pdfThe dividends received deduction Must exceed the applicable percentag.pdf
The dividends received deduction Must exceed the applicable percentag.pdflakshmijewellery
 
The chordae tendinae of the AV valves are anchored to the ___ of the .pdf
The chordae tendinae of the AV valves are anchored to the ___ of the .pdfThe chordae tendinae of the AV valves are anchored to the ___ of the .pdf
The chordae tendinae of the AV valves are anchored to the ___ of the .pdflakshmijewellery
 
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdfRead the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdflakshmijewellery
 
Q4. How are automated tools used in the maintenance of information .pdf
Q4. How are automated tools used in the maintenance of information .pdfQ4. How are automated tools used in the maintenance of information .pdf
Q4. How are automated tools used in the maintenance of information .pdflakshmijewellery
 

More from lakshmijewellery (20)

Write a shell command to substitute the first Nick to John in report.pdf
Write a shell command to substitute the first Nick to John in report.pdfWrite a shell command to substitute the first Nick to John in report.pdf
Write a shell command to substitute the first Nick to John in report.pdf
 
Why did the European empires in the Americas have such an enormously.pdf
Why did the European empires in the Americas have such an enormously.pdfWhy did the European empires in the Americas have such an enormously.pdf
Why did the European empires in the Americas have such an enormously.pdf
 
What were the unintended consequences of the Cuban Missile Crisis.pdf
What were the unintended consequences of the Cuban Missile Crisis.pdfWhat were the unintended consequences of the Cuban Missile Crisis.pdf
What were the unintended consequences of the Cuban Missile Crisis.pdf
 
What process occurs when bile is mixed with fats How does this proc.pdf
What process occurs when bile is mixed with fats How does this proc.pdfWhat process occurs when bile is mixed with fats How does this proc.pdf
What process occurs when bile is mixed with fats How does this proc.pdf
 
What is OBDC , Is it a program and what is the difference between .pdf
What is OBDC , Is it a program  and what is the difference between .pdfWhat is OBDC , Is it a program  and what is the difference between .pdf
What is OBDC , Is it a program and what is the difference between .pdf
 
This Capital includes O A. mineral resources. O B. the money in one.pdf
This Capital includes O A. mineral resources. O B. the money in one.pdfThis Capital includes O A. mineral resources. O B. the money in one.pdf
This Capital includes O A. mineral resources. O B. the money in one.pdf
 
What are the essential characteristics of cloud computingSolutio.pdf
What are the essential characteristics of cloud computingSolutio.pdfWhat are the essential characteristics of cloud computingSolutio.pdf
What are the essential characteristics of cloud computingSolutio.pdf
 
We live in a very complex and culturally diverse society. When we br.pdf
We live in a very complex and culturally diverse society. When we br.pdfWe live in a very complex and culturally diverse society. When we br.pdf
We live in a very complex and culturally diverse society. When we br.pdf
 
What are the values of the following expressions, assuming that n is.pdf
What are the values of the following expressions, assuming that n is.pdfWhat are the values of the following expressions, assuming that n is.pdf
What are the values of the following expressions, assuming that n is.pdf
 
True or FalseA budget variance is the difference between expected.pdf
True or FalseA budget variance is the difference between expected.pdfTrue or FalseA budget variance is the difference between expected.pdf
True or FalseA budget variance is the difference between expected.pdf
 
This level of measurement includes continuous measures A. Nominal; .pdf
This level of measurement includes continuous measures A. Nominal; .pdfThis level of measurement includes continuous measures A. Nominal; .pdf
This level of measurement includes continuous measures A. Nominal; .pdf
 
Throughout the middle ages European philosophers believed in…a sci.pdf
Throughout the middle ages European philosophers believed in…a sci.pdfThroughout the middle ages European philosophers believed in…a sci.pdf
Throughout the middle ages European philosophers believed in…a sci.pdf
 
The term intangible assets is used in accounting to denotea. suc.pdf
The term intangible assets is used in accounting to denotea. suc.pdfThe term intangible assets is used in accounting to denotea. suc.pdf
The term intangible assets is used in accounting to denotea. suc.pdf
 
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdfThe methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
 
The lagging strand is replicated with a series of Okazaki fragments .pdf
The lagging strand is replicated with a series of Okazaki fragments .pdfThe lagging strand is replicated with a series of Okazaki fragments .pdf
The lagging strand is replicated with a series of Okazaki fragments .pdf
 
The files etcpasswd and etcshadow can be manually edited. Why wo.pdf
The files etcpasswd and etcshadow can be manually edited. Why wo.pdfThe files etcpasswd and etcshadow can be manually edited. Why wo.pdf
The files etcpasswd and etcshadow can be manually edited. Why wo.pdf
 
The dividends received deduction Must exceed the applicable percentag.pdf
The dividends received deduction Must exceed the applicable percentag.pdfThe dividends received deduction Must exceed the applicable percentag.pdf
The dividends received deduction Must exceed the applicable percentag.pdf
 
The chordae tendinae of the AV valves are anchored to the ___ of the .pdf
The chordae tendinae of the AV valves are anchored to the ___ of the .pdfThe chordae tendinae of the AV valves are anchored to the ___ of the .pdf
The chordae tendinae of the AV valves are anchored to the ___ of the .pdf
 
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdfRead the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
 
Q4. How are automated tools used in the maintenance of information .pdf
Q4. How are automated tools used in the maintenance of information .pdfQ4. How are automated tools used in the maintenance of information .pdf
Q4. How are automated tools used in the maintenance of information .pdf
 

Recently uploaded

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
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
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
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
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
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
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
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
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
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
 
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...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
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
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

#include iostream #includestdlib.h using namespace std;str.pdf

  • 1. #include #include using namespace std; struct node { //Task 1 char val; node *next; }; void printList(node *head) { //Task 2 if (head == NULL) { cout << "Empty list" << endl; return; } node *temp = head; int count = 0; while(temp != NULL) { cout << "Node " << count << ": " << temp ->val << endl; count++; temp = temp->next; } } struct node *globalhead = NULL; void deepCopy(node *head1, node *head2) { //Task 3 if (head1 == NULL) { cout << "Empty list" << endl; return; } node *temp = head1; node *curr = NULL; node *prev = NULL; while(temp != NULL) { curr = (struct node *)malloc(sizeof(struct node)); curr->val = temp->val; if(prev==NULL){ head2 = curr;
  • 2. globalhead = curr; }else{ prev->next = curr; } prev = curr; temp = temp->next; } } int main() { //Task 4 // Example #1 node p00, p01, p02, p03, p10, p11, p12, p13; // List 1: A B B B p00.val = 'A'; p00.next = &p01; p01.val = 'B'; p01.next = &p02; p02.val = 'B'; p02.next = &p03; p03.val = 'B'; p03.next = NULL; p10.next = NULL; cout<<"First List:"< Solution //Tested on Windos OS Dev c++ /*********************LinkedList.cpp********************/ #include #include using namespace std; struct node { //Task 1 char val; node *next; }; void printList(node *head) { //Task 2 if (head == NULL) { cout << "Empty list" << endl; return; } node *temp = head;
  • 3. int count = 0; while(temp != NULL) { cout << "Node " << count << ": " << temp ->val << endl; count++; temp = temp->next; } } struct node *globalhead = NULL; void deepCopy(node *head1, node **head2) { //Task 3 if (head1 == NULL) { cout << "Empty list" << endl; return; } node *temp = head1; node *curr = NULL; node *prev = NULL; while(temp != NULL) { curr = (struct node *)malloc(sizeof(struct node)); curr->val = temp->val; curr->next = NULL; if(*head2==NULL){ *head2=curr; }else{ prev=*head2; while(prev->next!=NULL){ prev=prev->next; } prev->next=curr; } temp = temp->next; } } int main() { //Task 4 // Example #1 node p00, p01, p02, p03, p10, p11, p12, p13;
  • 4. // List 1: A B B B p00.val = 'A'; p00.next = &p01; p01.val = 'B'; p01.next = &p02; p02.val = 'B'; p02.next = &p03; p03.val = 'B'; p03.next = NULL; p10.next = NULL; cout<<"First List:"<