topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Tuesday March 19, 2024, 12:11 am
  • Proudly celebrating 15+ 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 14280 times)

h0meopathic

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 24
    • View Profile
    • Donate to Member
C# Palindrom Recursive Program
« on: April 17, 2007, 09:38 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 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
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #2 on: April 19, 2007, 10:04 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
  • *
  • default avatar
  • Posts: 24
    • View Profile
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #3 on: April 19, 2007, 03:43 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# [Select]
  1. namespace RecursivePalindromeTester
  2. {
  3.     class Palindrome
  4.     {
  5.         String str, another = "y";
  6.             int left, right;
  7.  
  8.             while (another.ToUpper() == "Y")
  9.             {
  10.                 Console.Out.WriteLine("Enter a potential Palindrome:");
  11.                 str = Console.In.ReadLine();
  12.  
  13.                 left = 0;
  14.                 right = str.Length - 1;
  15.  
  16.                 while (str[left] == str[right] && left < right)
  17.                 {
  18.                     left++;
  19.                     right--;
  20.                 }
  21.  
  22.                 Console.Out.WriteLine();
  23.  
  24.                 if (left < right)
  25.                     Console.Out.WriteLine("String is Not a Palindrome.");
  26.                 else
  27.                     Console.Out.WriteLine("String is a Palindrome.");
  28.                
  29.                 Console.Out.WriteLine();
  30.                 Console.Out.Write("Test another PalindromTester (Y/N)? ");
  31.                 another = Console.In.ReadLine();      
  32.     }
  33. }
« Last Edit: April 19, 2007, 04:03 PM by h0meopathic »

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #4 on: April 19, 2007, 03:52 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++ [Select]
  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

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #5 on: April 19, 2007, 08:43 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
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #6 on: April 20, 2007, 06:13 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: 59
  • hey!
    • View Profile
    • Personal Website
    • Donate to Member
Re: C# Palindrom Recursive Program
« Reply #7 on: April 06, 2009, 06:04 AM »
er.. can i post a C Program version?... its C language also right?...  :-[

cool.. my classmate also used a recursion in his palindrome..

nosh

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