SlideShare uma empresa Scribd logo
1 de 2
Baixar para ler offline
Need answer in C#
Concept Summary:
Recursion
For this assignment1 you will design a recursive method and the main program that calls the
recursive method.
1. This assignment has been adapted from the Roger Frank collection.
Description
Take a piece of paper and fold it in half. Unfold it and there is one fold, which I'll signify with a
"v". If you fold the paper twice (always keeping the folds in the same direction and the creases
parallel), it will have three folds when you unfold it, and they will be in a "^ v v" pattern. Fold a
piece of paper three times, and you will see "^ ^ v v ^ v v" as the sequence of folds.
Folding a piece of already folded paper sounds a lot like recursion, and indeed it is. In case you
can't see the algorithm, here it is:
If you fold a paper once, the fold pattern is "v".
For additional folds, it is the pattern you have only reversed and flipped over, then a "v"
fold, and then the pattern you already have tacked on the end.
Assignment:
Write a helper method reverse which takes in a string and returns the string backwards. For
example, if given Hello, it will return olleH
Hints (you dont have to use these, but they may be helpful):
You can convert a string to an array of characters using (Java)
string.toCharArray() or (C#) string.ToCharArray();
Once you have an array of characters, you can reverse them pretty
easily.
You can convert an array of characters back to a string with (Java)
String x=new String(charArray) or (C#) string x = new
string(charArray);
You may use a loop or recursion for this method.
Write a helper method which converts all ^ to v and all v to ^ in a string. It should take in and
return a string.
Hint: You may find (Java) string.replace() or (C#) String.Replace() useful. Write a static
method, paperFold, which is a recursive routine that returns a string
representing the fold pattern for a paper folded n times. The driver program will call the
paperFold method
As in many recursive solutions, expect the paperFold method to be extremely simple (and of
course recursive).
Main method in Java:
} }
Main method in C#:
}
Sample Output:
Submission Guidelines:
Youll submit one class on gradescope as Assignment 5. Please follow the posted submission
guidelines here:

Mais conteúdo relacionado

Semelhante a Need answer in C#Concept SummaryRecursionFor this assignmen.pdf

QUE 2Measuring Area of Irregular ShapesGeneral formulaThe gene.docx
QUE 2Measuring Area of Irregular ShapesGeneral formulaThe gene.docxQUE 2Measuring Area of Irregular ShapesGeneral formulaThe gene.docx
QUE 2Measuring Area of Irregular ShapesGeneral formulaThe gene.docx
amrit47
 
Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Real World Haskell: Lecture 4
Real World Haskell: Lecture 4
Bryan O'Sullivan
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
Masudul Haque
 

Semelhante a Need answer in C#Concept SummaryRecursionFor this assignmen.pdf (20)

Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in java
 
Intro To Formula Project
Intro To Formula ProjectIntro To Formula Project
Intro To Formula Project
 
Recursion.pptx
Recursion.pptxRecursion.pptx
Recursion.pptx
 
QUE 2Measuring Area of Irregular ShapesGeneral formulaThe gene.docx
QUE 2Measuring Area of Irregular ShapesGeneral formulaThe gene.docxQUE 2Measuring Area of Irregular ShapesGeneral formulaThe gene.docx
QUE 2Measuring Area of Irregular ShapesGeneral formulaThe gene.docx
 
Karnaugh mapping allaboutcircuits
Karnaugh mapping allaboutcircuitsKarnaugh mapping allaboutcircuits
Karnaugh mapping allaboutcircuits
 
Built-in Classes in JAVA
Built-in Classes in JAVABuilt-in Classes in JAVA
Built-in Classes in JAVA
 
Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Real World Haskell: Lecture 4
Real World Haskell: Lecture 4
 
scalar.pdf
scalar.pdfscalar.pdf
scalar.pdf
 
Derivative rules.docx
Derivative rules.docxDerivative rules.docx
Derivative rules.docx
 
L4
L4L4
L4
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
 
Get Fast C++ Homework Help
Get Fast C++ Homework HelpGet Fast C++ Homework Help
Get Fast C++ Homework Help
 
[컴퓨터비전과 인공지능] 6. 역전파 1
[컴퓨터비전과 인공지능] 6. 역전파 1[컴퓨터비전과 인공지능] 6. 역전파 1
[컴퓨터비전과 인공지능] 6. 역전파 1
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular Expressions
 
DiffEqPresent.ppt
DiffEqPresent.pptDiffEqPresent.ppt
DiffEqPresent.ppt
 
DiffEqPresent.ppt
DiffEqPresent.pptDiffEqPresent.ppt
DiffEqPresent.ppt
 
DiffEqPresent.ppt
DiffEqPresent.pptDiffEqPresent.ppt
DiffEqPresent.ppt
 
Differential Equations Presention powert point presentation
Differential Equations Presention powert point presentationDifferential Equations Presention powert point presentation
Differential Equations Presention powert point presentation
 

Mais de mkagarwalma

Need help with this assignment Sara Lange, a charge nurse at Sunny N.pdf
Need help with this assignment Sara Lange, a charge nurse at Sunny N.pdfNeed help with this assignment Sara Lange, a charge nurse at Sunny N.pdf
Need help with this assignment Sara Lange, a charge nurse at Sunny N.pdf
mkagarwalma
 
Nogalesin bir ksm Amerika Birleik Devletlerinde, Arizonada, dier .pdf
Nogalesin bir ksm Amerika Birleik Devletlerinde, Arizonada, dier .pdfNogalesin bir ksm Amerika Birleik Devletlerinde, Arizonada, dier .pdf
Nogalesin bir ksm Amerika Birleik Devletlerinde, Arizonada, dier .pdf
mkagarwalma
 
NEED HELP ASAP!!! doLikeTweet This function is used to add a like .pdf
NEED HELP ASAP!!! doLikeTweet This function is used to add a like .pdfNEED HELP ASAP!!! doLikeTweet This function is used to add a like .pdf
NEED HELP ASAP!!! doLikeTweet This function is used to add a like .pdf
mkagarwalma
 
Mountain Co. Ltd. is a small public company limited by shares formed.pdf
Mountain Co. Ltd. is a small public company limited by shares formed.pdfMountain Co. Ltd. is a small public company limited by shares formed.pdf
Mountain Co. Ltd. is a small public company limited by shares formed.pdf
mkagarwalma
 
Michael McCain Tweeting on the Maple Leaf Foods AccountOn January.pdf
Michael McCain Tweeting on the Maple Leaf Foods AccountOn January.pdfMichael McCain Tweeting on the Maple Leaf Foods AccountOn January.pdf
Michael McCain Tweeting on the Maple Leaf Foods AccountOn January.pdf
mkagarwalma
 

Mais de mkagarwalma (20)

OLS modelinde, �rneklem b�y�kl�� (N) arttk�a var( b1 ) ne olur o .pdf
OLS modelinde, �rneklem b�y�kl�� (N) arttk�a var( b1 ) ne olur o .pdfOLS modelinde, �rneklem b�y�kl�� (N) arttk�a var( b1 ) ne olur o .pdf
OLS modelinde, �rneklem b�y�kl�� (N) arttk�a var( b1 ) ne olur o .pdf
 
Need help with this assignment Sara Lange, a charge nurse at Sunny N.pdf
Need help with this assignment Sara Lange, a charge nurse at Sunny N.pdfNeed help with this assignment Sara Lange, a charge nurse at Sunny N.pdf
Need help with this assignment Sara Lange, a charge nurse at Sunny N.pdf
 
Obtuviste un contrato para producir 1000 widgets para el gobierno de.pdf
Obtuviste un contrato para producir 1000 widgets para el gobierno de.pdfObtuviste un contrato para producir 1000 widgets para el gobierno de.pdf
Obtuviste un contrato para producir 1000 widgets para el gobierno de.pdf
 
Observation First-year biology students at the University of Guyana.pdf
Observation First-year biology students at the University of Guyana.pdfObservation First-year biology students at the University of Guyana.pdf
Observation First-year biology students at the University of Guyana.pdf
 
NSZ Ltd. has equity of 15 Million and 10 debt of 20 Million. Cost o.pdf
NSZ Ltd. has equity of 15 Million and 10 debt of 20 Million. Cost o.pdfNSZ Ltd. has equity of 15 Million and 10 debt of 20 Million. Cost o.pdf
NSZ Ltd. has equity of 15 Million and 10 debt of 20 Million. Cost o.pdf
 
Now that Hurd has more specifically located the source of the econom.pdf
Now that Hurd has more specifically located the source of the econom.pdfNow that Hurd has more specifically located the source of the econom.pdf
Now that Hurd has more specifically located the source of the econom.pdf
 
Nogalesin bir ksm Amerika Birleik Devletlerinde, Arizonada, dier .pdf
Nogalesin bir ksm Amerika Birleik Devletlerinde, Arizonada, dier .pdfNogalesin bir ksm Amerika Birleik Devletlerinde, Arizonada, dier .pdf
Nogalesin bir ksm Amerika Birleik Devletlerinde, Arizonada, dier .pdf
 
Need Answer on Urgent Base PleaseUnderstand how technology is used.pdf
Need Answer on Urgent Base PleaseUnderstand how technology is used.pdfNeed Answer on Urgent Base PleaseUnderstand how technology is used.pdf
Need Answer on Urgent Base PleaseUnderstand how technology is used.pdf
 
NEED HELP ASAP!!! doLikeTweet This function is used to add a like .pdf
NEED HELP ASAP!!! doLikeTweet This function is used to add a like .pdfNEED HELP ASAP!!! doLikeTweet This function is used to add a like .pdf
NEED HELP ASAP!!! doLikeTweet This function is used to add a like .pdf
 
Need Answer on Urgent Base PleaseUnderstand the different types of.pdf
Need Answer on Urgent Base PleaseUnderstand the different types of.pdfNeed Answer on Urgent Base PleaseUnderstand the different types of.pdf
Need Answer on Urgent Base PleaseUnderstand the different types of.pdf
 
Need Answer on Urgent Base PleaseUnderstand the drivers and influe.pdf
Need Answer on Urgent Base PleaseUnderstand the drivers and influe.pdfNeed Answer on Urgent Base PleaseUnderstand the drivers and influe.pdf
Need Answer on Urgent Base PleaseUnderstand the drivers and influe.pdf
 
Nancy had an accident that resulted in injuries to three people. The.pdf
Nancy had an accident that resulted in injuries to three people. The.pdfNancy had an accident that resulted in injuries to three people. The.pdf
Nancy had an accident that resulted in injuries to three people. The.pdf
 
Nakamura, CPA, has accepted an engagement to audit the financial sta.pdf
Nakamura, CPA, has accepted an engagement to audit the financial sta.pdfNakamura, CPA, has accepted an engagement to audit the financial sta.pdf
Nakamura, CPA, has accepted an engagement to audit the financial sta.pdf
 
Mountain Co. Ltd. is a small public company limited by shares formed.pdf
Mountain Co. Ltd. is a small public company limited by shares formed.pdfMountain Co. Ltd. is a small public company limited by shares formed.pdf
Mountain Co. Ltd. is a small public company limited by shares formed.pdf
 
More than a year into the COVID-19 pandemic, the world continues the.pdf
More than a year into the COVID-19 pandemic, the world continues the.pdfMore than a year into the COVID-19 pandemic, the world continues the.pdf
More than a year into the COVID-19 pandemic, the world continues the.pdf
 
Monique is a life insurance agent in a small company in Ontario. Rec.pdf
Monique is a life insurance agent in a small company in Ontario. Rec.pdfMonique is a life insurance agent in a small company in Ontario. Rec.pdf
Monique is a life insurance agent in a small company in Ontario. Rec.pdf
 
Mesajnz �slup ve �slup a�sndan deerlendirdikten sonra aadakilerden h.pdf
Mesajnz �slup ve �slup a�sndan deerlendirdikten sonra aadakilerden h.pdfMesajnz �slup ve �slup a�sndan deerlendirdikten sonra aadakilerden h.pdf
Mesajnz �slup ve �slup a�sndan deerlendirdikten sonra aadakilerden h.pdf
 
Miguel contributed substantially appreciated property to the MR Part.pdf
Miguel contributed substantially appreciated property to the MR Part.pdfMiguel contributed substantially appreciated property to the MR Part.pdf
Miguel contributed substantially appreciated property to the MR Part.pdf
 
Mia will retire 10 years from now and wants to establish a fund toda.pdf
Mia will retire 10 years from now and wants to establish a fund toda.pdfMia will retire 10 years from now and wants to establish a fund toda.pdf
Mia will retire 10 years from now and wants to establish a fund toda.pdf
 
Michael McCain Tweeting on the Maple Leaf Foods AccountOn January.pdf
Michael McCain Tweeting on the Maple Leaf Foods AccountOn January.pdfMichael McCain Tweeting on the Maple Leaf Foods AccountOn January.pdf
Michael McCain Tweeting on the Maple Leaf Foods AccountOn January.pdf
 

Último

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Último (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).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
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 

Need answer in C#Concept SummaryRecursionFor this assignmen.pdf

  • 1. Need answer in C# Concept Summary: Recursion For this assignment1 you will design a recursive method and the main program that calls the recursive method. 1. This assignment has been adapted from the Roger Frank collection. Description Take a piece of paper and fold it in half. Unfold it and there is one fold, which I'll signify with a "v". If you fold the paper twice (always keeping the folds in the same direction and the creases parallel), it will have three folds when you unfold it, and they will be in a "^ v v" pattern. Fold a piece of paper three times, and you will see "^ ^ v v ^ v v" as the sequence of folds. Folding a piece of already folded paper sounds a lot like recursion, and indeed it is. In case you can't see the algorithm, here it is: If you fold a paper once, the fold pattern is "v". For additional folds, it is the pattern you have only reversed and flipped over, then a "v" fold, and then the pattern you already have tacked on the end. Assignment: Write a helper method reverse which takes in a string and returns the string backwards. For example, if given Hello, it will return olleH Hints (you dont have to use these, but they may be helpful): You can convert a string to an array of characters using (Java) string.toCharArray() or (C#) string.ToCharArray(); Once you have an array of characters, you can reverse them pretty easily. You can convert an array of characters back to a string with (Java) String x=new String(charArray) or (C#) string x = new string(charArray); You may use a loop or recursion for this method. Write a helper method which converts all ^ to v and all v to ^ in a string. It should take in and return a string. Hint: You may find (Java) string.replace() or (C#) String.Replace() useful. Write a static method, paperFold, which is a recursive routine that returns a string representing the fold pattern for a paper folded n times. The driver program will call the paperFold method
  • 2. As in many recursive solutions, expect the paperFold method to be extremely simple (and of course recursive). Main method in Java: } } Main method in C#: } Sample Output: Submission Guidelines: Youll submit one class on gradescope as Assignment 5. Please follow the posted submission guidelines here: