Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • August 31, 2015, 12:48:22 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: C# Palindrom Recursive Program  (Read 8120 times)

h0meopathic

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 24
    • View Profile
    • Donate to Member
C# Palindrom Recursive Program
« on: April 17, 2007, 09:38:11 PM »
I have to make a program using C# that makes a PalindromeTester using Recursive methods. I can make the program using normal methods i.e. while statements and nested if statements. I can't figure it out even after doing a lot of research and while looking at sudocode from someone writing it in java. Could someone help. I don't necessarily want someone to do the work for me but help me think it through using the c# language. I would talk to my Teacher about it but she can't bring herself to coming to my level. People with Ph.D's shouldn't be allowed to teach low level college classes. 

Renox

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 58
    • View Profile
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #1 on: April 19, 2007, 09:42:45 AM »
Homeo, I am glad that you took my advice and registered on the forums! You'll find that the people here are EXTREMELY helpful and ALWAYS provide knowledgeable solutions...

I am put together a couple things to take a look at... I haven't really had the time to put together some coding but I have found some that has already been put into use... If you or anyone else knows java well here is some coding that will make you smile: http://www.public.as...alindromeTester.java... If anyone could convert this from Java into C# that would be wonderful... I am not too go with Java yet..

Here is a link for Recursion that you might want to look at:http://en.wikipedia..../Recursive_algorithm

I will try to look for some more things that might be beneficial to you... If anyone else can help, please do!

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #2 on: April 19, 2007, 10:04:30 AM »
h0meopathic ,

I am sure many of us here would be happy to help, but could you please help us help you?

I can make the program using normal methods i.e. while statements and nested if statements.

Attach the source code file to your posting so we can see what you have. Also attach the java pseudo code or provide a link to it.

h0meopathic

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 24
    • View Profile
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #3 on: April 19, 2007, 03:43:42 PM »
This is the Palindrom in non recursive format but I need to put it in recursive format. From my understanding I should put most of this code in a method, probably in another class, then have the main method call upon it every time the system loops
==========================================================
Code: C#
  1.  
  2. namespace RecursivePalindromeTester
  3. {
  4.     class Palindrome
  5.     {
  6.         String str, another = "y";
  7.             int left, right;
  8.  
  9.             while (another.ToUpper() == "Y")
  10.             {
  11.                 Console.Out.WriteLine("Enter a potential Palindrome:");
  12.                 str = Console.In.ReadLine();
  13.  
  14.                 left = 0;
  15.                 right = str.Length - 1;
  16.  
  17.                 while (str[left] == str[right] && left < right)
  18.                 {
  19.                     left++;
  20.                     right--;
  21.                 }
  22.  
  23.                 Console.Out.WriteLine();
  24.  
  25.                 if (left < right)
  26.                     Console.Out.WriteLine("String is Not a Palindrome.");
  27.                 else
  28.                     Console.Out.WriteLine("String is a Palindrome.");
  29.                
  30.                 Console.Out.WriteLine();
  31.                 Console.Out.Write("Test another PalindromTester (Y/N)? ");
  32.                 another = Console.In.ReadLine();      
  33.     }
  34. }
  35.  
« Last Edit: April 19, 2007, 04:03:06 PM by h0meopathic »

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #4 on: April 19, 2007, 03:52:31 PM »
h0meopathic,

Edit your posting and use the "insert code" button and choose the proper highlighting language. That will make it look all nice and pretty, as well as make it easier for others to read.

For example:
Code: C++
  1. String str, another = "y";
  2. int left, right;
  3.  
  4. while (another.ToUpper() == "Y")
  5. {
  6.     Console.Out.WriteLine("Enter a potential Palindrome:");
  7.     str = Console.In.ReadLine();
  8.  
  9.     left = 0;
  10.     right = str.Length - 1;
  11.  
  12.     while (str
  13.  

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,087
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #5 on: April 19, 2007, 08:43:16 PM »
A few months ago I started a project that uses recursion to search for all files in a directory, and all files in each subdirectories, and any files in subdirectories of those subdirectories ... ad nauseum.  I haven't finished it, but what's there, works.  Might help, because shows an example of C# code for recursion.

http://www1.webng.co...cursiveDirSearch.zip

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #6 on: April 20, 2007, 06:13:57 PM »
A couple of hints.

  • Your recursive function is going to be built around the part of your code that is repeated. So lines 16 through 20 is what you should be looking at.
  • There has to be some test to know when to stop recursing. So lines 16 through 20 should be where you look.
  • In order to do recursion you need a section of code to call itself, so put it in a function.

How's your progress?

jeremejazz

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 58
  • hey!
    • View Profile
    • Jereme's Pinboard
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #7 on: April 06, 2009, 06:04:07 AM »
er.. can i post a C Program version?... its C language also right?...  :-[

cool.. my classmate also used a recursion in his palindrome..
:) I love coding

nosh

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,407
    • View Profile
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #8 on: April 06, 2009, 07:33:14 AM »
- Post deleted.
« Last Edit: April 06, 2009, 07:42:41 AM by nosh »