Thread: Help me with this Hash Table assignment..PLESE I beg you guys.

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    1

    Help me with this Hash Table assignment..PLESE I beg you guys.

    hello everyone...

    can you help me with this assignment about hash tables..
    I run the code on a linux machine and gave me errors..

    the assignment in attachment

    and here is my code:

    http://www.mediafire.com/file/hophmdnnyze/Asem.zip

    can anyone fix this please...I need to hand it today..

    thank you all
    Asem

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Please refer to the homework policy.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    What errors did it give you?

    ETA: After fixing a few warnings related to the comparison of unsigned/signed and reusing counter variables in your for(;;) constructs, it compiled, ran and seemed to at least work without crashing. This is not to say that it necessarily generates the results you expect, but hopefully this is a stepping-off point for you.

    To fix the counter variable problem, change this:
    Code:
    string swapLetters(string NodeData,int lettertoswap)
    {
        string output="";
        int len=NodeData.length();
    	for(int i=0;i<lettertoswap;i++)
             output=output+NodeData[i];
        output=output+NodeData[i+1];
        output=output+NodeData[i];
    	for( i=lettertoswap+2;i<len;i++)
             output=output+NodeData[i];
        return output;
    }
    to this:
    Code:
    string swapLetters(string NodeData,int lettertoswap)
    {
        string output="";
        int len=NodeData.length();
        int i = 0;
        for(i=0;i<lettertoswap;i++)
            output=output+NodeData[i];
        output=output+NodeData[i+1];
        output=output+NodeData[i];
        for( i=lettertoswap+2;i<len;i++)
            output=output+NodeData[i];
        return output;
    }
    Last edited by rags_to_riches; 08-25-2008 at 12:40 PM.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    I bet if you spent the same amount of time researching your errors instead of shotgunning forums begging people to finish your homework for you, you might actually have made the deadline. Consider this a learning experience.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array of Linked Lists - Hash table
    By FortinsM3 in forum C Programming
    Replies: 12
    Last Post: 02-25-2009, 10:20 PM
  2. Writing array, to file
    By zootreeves in forum C Programming
    Replies: 9
    Last Post: 09-08-2007, 05:06 PM
  3. Duplicate at Hash Table
    By DarrenY in forum C Programming
    Replies: 1
    Last Post: 05-10-2007, 02:31 AM
  4. Replies: 1
    Last Post: 10-27-2006, 01:21 PM
  5. Hash Table Problem.
    By penance in forum C Programming
    Replies: 9
    Last Post: 07-24-2005, 01:03 PM