• Post Reply Bookmark Topic Watch Topic
  • New Topic

App that performs add. and sub. of arbitrarily large pos int's  RSS feed

 
R Wall
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to implement a application that performs addition and subtraction of arbitrarily large positive integers. In doing so I am not allowed to use any math packages, only ADT's. I beleive a doubly linked list would be easiest and most efficient but am having trouble coding the idea. Thanks.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you thinking of using a LinkedList to implement this? What is your current strategy?
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I think arrays would be much easier to work with than linked lists. Unless you plan to use the LinkedList class built into the Java API; but even then I think arrays would still be easier.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMHO, I think it would be much easier to determine what Data Structure is best, if we had some idea of what the algorithm, that the original poster was thinking of using. You might get a better answer, and maybe some help, if you give us idea of how you are going to accomplish the task.

Henry
 
R Wall
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using an array how would the add method be implemented?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without trying to sound snippy: That's for you to figure out. This sounds like a homework assigment, and we don't do peoples homework for them. If, on the other hand, you have an idea of what to do but have trouble implementing it, then come back here, and we'll be happy to help you get going again.
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by R Wall:
Using an array how would the add method be implemented?
I don't think I'm giving too much away if I suggest you use some square boxes drawn on a piece of paper to simulate the arrays. Write the numbers in the square boxes, one digit per box. Put one number above the other. Then, try to recall the way you add two numbers (the way you learned when you were about 8 years old but now do without thinking). Convert that into Java code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!