• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

memory limit crossed (assignment)

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1359
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which exception do you get running this program?

I posted some information that might help you:
http://www.ourdailycodes.com/2013/08/inside-java-jvm-memory-structure.html
http://www.ourdailycodes.com/2013/09/inside-java-jvm-memory-structure-2.html
http://www.ourdailycodes.com/2013/09/inside-java-jvm-memory-structure-3.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic