SlideShare a Scribd company logo
1 of 3
Download to read offline
C# code please
Write a program that creates a link list object of 10 characters, then creates a second list object
containing a copy of the first list but in reverse order.
Solution
using System;
class LinkedList
{
private char data;
private LinkedList next;
public LinkedList()
{
data = 'c';
next = null;
}
public LinkedList(char value)
{
data = value;
next = null;
}
public LinkedList Append(char value)
{
LinkedList node = new LinkedList(value);
if(this.next == null)
{
// Easy to handle
node.next = null; // already set in constructor
this.next = node;
}
else
{
// Insert in the middle
LinkedList temp = this.next;
node.next = temp;
this.next = node;
}
return node;
}
public void Display(LinkedList node)
{
if(node == null)
node = this;
System.Console.WriteLine("  LinkedList:  ");
while(node != null)
{
System.Console.Write(node.data+" -> ");
node = node.next;
}
System.Console.Write(" ");
}
public LinkedList Reverse_with_copy(LinkedList head)
{
LinkedList p = head;
LinkedList newhead = null;
while(true)
{
if(p == null)
return newhead;
LinkedList newnode = new LinkedList(p.data);
newnode.next = newhead;
newhead = newnode;
p = p.next;
}
}
}
class Program
{
static void Main(string[] args)
{
LinkedList head = new LinkedList('a');
LinkedList p = head.Append('c');
p = p.Append('e');
p = p.Append('h');
p = p.Append('b');
p = p.Append('d');
p = p.Append('f');
p = p.Append('g');
head.Display(null);
LinkedList newhead = head.Reverse_with_copy(head);
newhead.Display(null);
}
}
/* sample output
*/

More Related Content

Similar to C# code pleaseWrite a program that creates a link list object of 1.pdf

Java AssignmentUsing the ListNode.java file below Write method.pdf
Java AssignmentUsing the ListNode.java file below Write method.pdfJava AssignmentUsing the ListNode.java file below Write method.pdf
Java AssignmentUsing the ListNode.java file below Write method.pdfambersushil
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdfalmaniaeyewear
 
MO 2020 DS Applications of Linked List 1 AB.ppt
MO 2020 DS Applications of Linked List 1 AB.pptMO 2020 DS Applications of Linked List 1 AB.ppt
MO 2020 DS Applications of Linked List 1 AB.pptshashankbhadouria4
 
Create a C program which auto-completes suggestions when beginning t.pdf
Create a C program which auto-completes suggestions when beginning t.pdfCreate a C program which auto-completes suggestions when beginning t.pdf
Create a C program which auto-completes suggestions when beginning t.pdffedosys
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Balwant Gorad
 
You can list anything, it doesnt matter. I just want to see code f.pdf
You can list anything, it doesnt matter. I just want to see code f.pdfYou can list anything, it doesnt matter. I just want to see code f.pdf
You can list anything, it doesnt matter. I just want to see code f.pdffashionbigchennai
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03Nasir Mehmood
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdffreddysarabia1
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfferoz544
 
Write an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdfWrite an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdfArrowdeepak
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfAnkitchhabra28
 
Using visual studio 2022- a C# windows form application- and your Doub.pdf
Using visual studio 2022- a C# windows form application- and your Doub.pdfUsing visual studio 2022- a C# windows form application- and your Doub.pdf
Using visual studio 2022- a C# windows form application- and your Doub.pdfacteleshoppe
 
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
 
Database By Salman Mushtaq
Database By Salman MushtaqDatabase By Salman Mushtaq
Database By Salman MushtaqSalman Mushtaq
 
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
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfEricvtJFraserr
 
Chapter 5: linked list data structure
Chapter 5: linked list data structureChapter 5: linked list data structure
Chapter 5: linked list data structureMahmoud Alfarra
 
For this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxFor this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxmckellarhastings
 

Similar to C# code pleaseWrite a program that creates a link list object of 1.pdf (20)

Java AssignmentUsing the ListNode.java file below Write method.pdf
Java AssignmentUsing the ListNode.java file below Write method.pdfJava AssignmentUsing the ListNode.java file below Write method.pdf
Java AssignmentUsing the ListNode.java file below Write method.pdf
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 
MO 2020 DS Applications of Linked List 1 AB.ppt
MO 2020 DS Applications of Linked List 1 AB.pptMO 2020 DS Applications of Linked List 1 AB.ppt
MO 2020 DS Applications of Linked List 1 AB.ppt
 
Create a C program which auto-completes suggestions when beginning t.pdf
Create a C program which auto-completes suggestions when beginning t.pdfCreate a C program which auto-completes suggestions when beginning t.pdf
Create a C program which auto-completes suggestions when beginning t.pdf
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
 
You can list anything, it doesnt matter. I just want to see code f.pdf
You can list anything, it doesnt matter. I just want to see code f.pdfYou can list anything, it doesnt matter. I just want to see code f.pdf
You can list anything, it doesnt matter. I just want to see code f.pdf
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
 
Ch17
Ch17Ch17
Ch17
 
Write an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdfWrite an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdf
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdf
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 
Using visual studio 2022- a C# windows form application- and your Doub.pdf
Using visual studio 2022- a C# windows form application- and your Doub.pdfUsing visual studio 2022- a C# windows form application- and your Doub.pdf
Using visual studio 2022- a C# windows form application- and your Doub.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
 
Database By Salman Mushtaq
Database By Salman MushtaqDatabase By Salman Mushtaq
Database By Salman Mushtaq
 
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
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
 
Chapter 5: linked list data structure
Chapter 5: linked list data structureChapter 5: linked list data structure
Chapter 5: linked list data structure
 
For this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxFor this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docx
 

More from duttakajal70

Explain the relevance of the rules against hearsay to digital eviden.pdf
Explain the relevance of the rules against hearsay to digital eviden.pdfExplain the relevance of the rules against hearsay to digital eviden.pdf
Explain the relevance of the rules against hearsay to digital eviden.pdfduttakajal70
 
Electric and magnetic fields in an electromagnetic wave are alway.pdf
Electric and magnetic fields in an electromagnetic wave are alway.pdfElectric and magnetic fields in an electromagnetic wave are alway.pdf
Electric and magnetic fields in an electromagnetic wave are alway.pdfduttakajal70
 
During our laboratory exercise on cellular the Krebs cycle in.pdf
During our laboratory exercise on cellular the Krebs cycle in.pdfDuring our laboratory exercise on cellular the Krebs cycle in.pdf
During our laboratory exercise on cellular the Krebs cycle in.pdfduttakajal70
 
25. On January 3, Pippin Corporation purchased 1,900 shares of the c.pdf
25. On January 3, Pippin Corporation purchased 1,900 shares of the c.pdf25. On January 3, Pippin Corporation purchased 1,900 shares of the c.pdf
25. On January 3, Pippin Corporation purchased 1,900 shares of the c.pdfduttakajal70
 
Define filtration and active transport.SolutionFiltration is t.pdf
Define filtration and active transport.SolutionFiltration is t.pdfDefine filtration and active transport.SolutionFiltration is t.pdf
Define filtration and active transport.SolutionFiltration is t.pdfduttakajal70
 
Why wouldnt you want to post a payment against an invoice directly.pdf
Why wouldnt you want to post a payment against an invoice directly.pdfWhy wouldnt you want to post a payment against an invoice directly.pdf
Why wouldnt you want to post a payment against an invoice directly.pdfduttakajal70
 
Cisco routers and switches use two configuration files. Where is the.pdf
Cisco routers and switches use two configuration files. Where is the.pdfCisco routers and switches use two configuration files. Where is the.pdf
Cisco routers and switches use two configuration files. Where is the.pdfduttakajal70
 
Which of the following is a simple compressible system A mixtur.pdf
Which of the following is a simple compressible system  A mixtur.pdfWhich of the following is a simple compressible system  A mixtur.pdf
Which of the following is a simple compressible system A mixtur.pdfduttakajal70
 
Which of the following statements is (are) trueI Walls Street i.pdf
Which of the following statements is (are) trueI  Walls Street i.pdfWhich of the following statements is (are) trueI  Walls Street i.pdf
Which of the following statements is (are) trueI Walls Street i.pdfduttakajal70
 
What would be the most effective method of reducing the incidence of .pdf
What would be the most effective method of reducing the incidence of .pdfWhat would be the most effective method of reducing the incidence of .pdf
What would be the most effective method of reducing the incidence of .pdfduttakajal70
 
What is a micelle What is a vesicle How are these structures the s.pdf
What is a micelle What is a vesicle How are these structures the s.pdfWhat is a micelle What is a vesicle How are these structures the s.pdf
What is a micelle What is a vesicle How are these structures the s.pdfduttakajal70
 
To determine her breathing rate, Miranda divides up her day into thre.pdf
To determine her breathing rate, Miranda divides up her day into thre.pdfTo determine her breathing rate, Miranda divides up her day into thre.pdf
To determine her breathing rate, Miranda divides up her day into thre.pdfduttakajal70
 
On January 29th, 2014, the Royal Caribbean cruise ship Explorer of.pdf
On January 29th, 2014, the Royal Caribbean cruise ship Explorer of.pdfOn January 29th, 2014, the Royal Caribbean cruise ship Explorer of.pdf
On January 29th, 2014, the Royal Caribbean cruise ship Explorer of.pdfduttakajal70
 
Name and describe the six main types of lymphatic cells, discuss the.pdf
Name and describe the six main types of lymphatic cells, discuss the.pdfName and describe the six main types of lymphatic cells, discuss the.pdf
Name and describe the six main types of lymphatic cells, discuss the.pdfduttakajal70
 
Let X1, X2, . . . , Xn be n independent continuous random variables,.pdf
Let X1, X2, . . . , Xn be n independent continuous random variables,.pdfLet X1, X2, . . . , Xn be n independent continuous random variables,.pdf
Let X1, X2, . . . , Xn be n independent continuous random variables,.pdfduttakajal70
 
Java Program using RecursionWrite a program that reads in a file .pdf
Java Program using RecursionWrite a program that reads in a file .pdfJava Program using RecursionWrite a program that reads in a file .pdf
Java Program using RecursionWrite a program that reads in a file .pdfduttakajal70
 
In major league baseball, there are 5 teams in the Eastern division .pdf
In major league baseball, there are 5 teams in the Eastern division .pdfIn major league baseball, there are 5 teams in the Eastern division .pdf
In major league baseball, there are 5 teams in the Eastern division .pdfduttakajal70
 
Im off by a minus sign, can you find my error In a previous probl.pdf
Im off by a minus sign, can you find my error In a previous probl.pdfIm off by a minus sign, can you find my error In a previous probl.pdf
Im off by a minus sign, can you find my error In a previous probl.pdfduttakajal70
 
If the characteristic followed in the pedigree is X-linked recessiv.pdf
If the characteristic followed in the pedigree is X-linked recessiv.pdfIf the characteristic followed in the pedigree is X-linked recessiv.pdf
If the characteristic followed in the pedigree is X-linked recessiv.pdfduttakajal70
 
create a Tic Tac Toe game using JSP Scripting elements and a JSP pag.pdf
create a Tic Tac Toe game using JSP Scripting elements and a JSP pag.pdfcreate a Tic Tac Toe game using JSP Scripting elements and a JSP pag.pdf
create a Tic Tac Toe game using JSP Scripting elements and a JSP pag.pdfduttakajal70
 

More from duttakajal70 (20)

Explain the relevance of the rules against hearsay to digital eviden.pdf
Explain the relevance of the rules against hearsay to digital eviden.pdfExplain the relevance of the rules against hearsay to digital eviden.pdf
Explain the relevance of the rules against hearsay to digital eviden.pdf
 
Electric and magnetic fields in an electromagnetic wave are alway.pdf
Electric and magnetic fields in an electromagnetic wave are alway.pdfElectric and magnetic fields in an electromagnetic wave are alway.pdf
Electric and magnetic fields in an electromagnetic wave are alway.pdf
 
During our laboratory exercise on cellular the Krebs cycle in.pdf
During our laboratory exercise on cellular the Krebs cycle in.pdfDuring our laboratory exercise on cellular the Krebs cycle in.pdf
During our laboratory exercise on cellular the Krebs cycle in.pdf
 
25. On January 3, Pippin Corporation purchased 1,900 shares of the c.pdf
25. On January 3, Pippin Corporation purchased 1,900 shares of the c.pdf25. On January 3, Pippin Corporation purchased 1,900 shares of the c.pdf
25. On January 3, Pippin Corporation purchased 1,900 shares of the c.pdf
 
Define filtration and active transport.SolutionFiltration is t.pdf
Define filtration and active transport.SolutionFiltration is t.pdfDefine filtration and active transport.SolutionFiltration is t.pdf
Define filtration and active transport.SolutionFiltration is t.pdf
 
Why wouldnt you want to post a payment against an invoice directly.pdf
Why wouldnt you want to post a payment against an invoice directly.pdfWhy wouldnt you want to post a payment against an invoice directly.pdf
Why wouldnt you want to post a payment against an invoice directly.pdf
 
Cisco routers and switches use two configuration files. Where is the.pdf
Cisco routers and switches use two configuration files. Where is the.pdfCisco routers and switches use two configuration files. Where is the.pdf
Cisco routers and switches use two configuration files. Where is the.pdf
 
Which of the following is a simple compressible system A mixtur.pdf
Which of the following is a simple compressible system  A mixtur.pdfWhich of the following is a simple compressible system  A mixtur.pdf
Which of the following is a simple compressible system A mixtur.pdf
 
Which of the following statements is (are) trueI Walls Street i.pdf
Which of the following statements is (are) trueI  Walls Street i.pdfWhich of the following statements is (are) trueI  Walls Street i.pdf
Which of the following statements is (are) trueI Walls Street i.pdf
 
What would be the most effective method of reducing the incidence of .pdf
What would be the most effective method of reducing the incidence of .pdfWhat would be the most effective method of reducing the incidence of .pdf
What would be the most effective method of reducing the incidence of .pdf
 
What is a micelle What is a vesicle How are these structures the s.pdf
What is a micelle What is a vesicle How are these structures the s.pdfWhat is a micelle What is a vesicle How are these structures the s.pdf
What is a micelle What is a vesicle How are these structures the s.pdf
 
To determine her breathing rate, Miranda divides up her day into thre.pdf
To determine her breathing rate, Miranda divides up her day into thre.pdfTo determine her breathing rate, Miranda divides up her day into thre.pdf
To determine her breathing rate, Miranda divides up her day into thre.pdf
 
On January 29th, 2014, the Royal Caribbean cruise ship Explorer of.pdf
On January 29th, 2014, the Royal Caribbean cruise ship Explorer of.pdfOn January 29th, 2014, the Royal Caribbean cruise ship Explorer of.pdf
On January 29th, 2014, the Royal Caribbean cruise ship Explorer of.pdf
 
Name and describe the six main types of lymphatic cells, discuss the.pdf
Name and describe the six main types of lymphatic cells, discuss the.pdfName and describe the six main types of lymphatic cells, discuss the.pdf
Name and describe the six main types of lymphatic cells, discuss the.pdf
 
Let X1, X2, . . . , Xn be n independent continuous random variables,.pdf
Let X1, X2, . . . , Xn be n independent continuous random variables,.pdfLet X1, X2, . . . , Xn be n independent continuous random variables,.pdf
Let X1, X2, . . . , Xn be n independent continuous random variables,.pdf
 
Java Program using RecursionWrite a program that reads in a file .pdf
Java Program using RecursionWrite a program that reads in a file .pdfJava Program using RecursionWrite a program that reads in a file .pdf
Java Program using RecursionWrite a program that reads in a file .pdf
 
In major league baseball, there are 5 teams in the Eastern division .pdf
In major league baseball, there are 5 teams in the Eastern division .pdfIn major league baseball, there are 5 teams in the Eastern division .pdf
In major league baseball, there are 5 teams in the Eastern division .pdf
 
Im off by a minus sign, can you find my error In a previous probl.pdf
Im off by a minus sign, can you find my error In a previous probl.pdfIm off by a minus sign, can you find my error In a previous probl.pdf
Im off by a minus sign, can you find my error In a previous probl.pdf
 
If the characteristic followed in the pedigree is X-linked recessiv.pdf
If the characteristic followed in the pedigree is X-linked recessiv.pdfIf the characteristic followed in the pedigree is X-linked recessiv.pdf
If the characteristic followed in the pedigree is X-linked recessiv.pdf
 
create a Tic Tac Toe game using JSP Scripting elements and a JSP pag.pdf
create a Tic Tac Toe game using JSP Scripting elements and a JSP pag.pdfcreate a Tic Tac Toe game using JSP Scripting elements and a JSP pag.pdf
create a Tic Tac Toe game using JSP Scripting elements and a JSP pag.pdf
 

Recently uploaded

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 

Recently uploaded (20)

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

C# code pleaseWrite a program that creates a link list object of 1.pdf

  • 1. C# code please Write a program that creates a link list object of 10 characters, then creates a second list object containing a copy of the first list but in reverse order. Solution using System; class LinkedList { private char data; private LinkedList next; public LinkedList() { data = 'c'; next = null; } public LinkedList(char value) { data = value; next = null; } public LinkedList Append(char value) { LinkedList node = new LinkedList(value); if(this.next == null) { // Easy to handle node.next = null; // already set in constructor this.next = node; } else { // Insert in the middle LinkedList temp = this.next;
  • 2. node.next = temp; this.next = node; } return node; } public void Display(LinkedList node) { if(node == null) node = this; System.Console.WriteLine(" LinkedList: "); while(node != null) { System.Console.Write(node.data+" -> "); node = node.next; } System.Console.Write(" "); } public LinkedList Reverse_with_copy(LinkedList head) { LinkedList p = head; LinkedList newhead = null; while(true) { if(p == null) return newhead; LinkedList newnode = new LinkedList(p.data); newnode.next = newhead; newhead = newnode; p = p.next; } } } class Program { static void Main(string[] args) {
  • 3. LinkedList head = new LinkedList('a'); LinkedList p = head.Append('c'); p = p.Append('e'); p = p.Append('h'); p = p.Append('b'); p = p.Append('d'); p = p.Append('f'); p = p.Append('g'); head.Display(null); LinkedList newhead = head.Reverse_with_copy(head); newhead.Display(null); } } /* sample output */