• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

memory limit crossed (assignment)

 
Muhammad Salman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I have an assignment in which I have to create a program which decodea message. As an input I am given a file with keys and messages. The file format is

no of key/message pairs
key
message
..
..

The message I have is always lowercase string seperated by spaces, for example : hello world. The key I am provided it always integer, for example : 1595.
Now, what I have to do here is that I have to decode and the logic for that is that I have to shift the letters in the message by the given number and I have to move from left to right and then right to left for the number. For example : considering the above key and the message

h+1=i, e+5=j, l+9=u, l+5=q

Now that we used all the digits, we do it again from right to left:

o+5=t, the space is discarded, w+9=f, o+5=t, r+1=s

we repeat the process, starting from left to right:

l+1=m, d+5=i

The result is: ijuqt ftsmi.


So, i achieve this result but my program fails because it exceeds the memory limit. Below is my program if someone can help me I would be grateful
 
Claude Moore
Ranch Hand
Posts: 817
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean with "program terminates because exceedes memory limit" ? Do you have a Stack Overflow error or and Heap Memory error ? (I don't remember exact names of these exceptions, sorry)

Apparently I cannot see in your code possibile endless loops or endless recursion calls to get such errors, at least if number of tests is enough small...
 
Luan Cestari
Ranch Hand
Posts: 172
C++ Redhat Ruby
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic