wu :: forums
« wu :: forums - Numbers as Linked Lists »

Welcome, Guest. Please Login or Register.
Dec 23rd, 2024, 10:51am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Grimbal, Icarus, ThudnBlunder, towr, william wu, SMQ, Eigenray)
   Numbers as Linked Lists
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Numbers as Linked Lists  (Read 702 times)
Ding Dong
Guest

Email

Numbers as Linked Lists  
« on: Jun 8th, 2005, 3:07am »
Quote Quote Modify Modify Remove Remove

Hi,
 
 I got this question in a Microsoft interview.  
 
1) Design a struct to hold large integers(I suggested a linked list)
 
2) How will you efficiently perform operations + and * on two given large integers and store the result in the same struct.
 
Any solutions that you can think of?
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Numbers as Linked Lists  
« Reply #1 on: Jun 8th, 2005, 4:00am »
Quote Quote Modify Modify

Multiplication is the trickiest bit.
You can do better than simple repeated addition, O(n^2). I think at least as well as O(n log(n))............. But I haven't the time to work it out now Tongue
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
SMQ
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 2084
Re: Numbers as Linked Lists  
« Reply #2 on: Jun 8th, 2005, 5:26am »
Quote Quote Modify Modify

You can indeed do as well as O(n log(n)) using an FFT-style "butterfly" approach.  See, for example, the documentation for the Gnu Multi-Precision math library at http://www.swox.com/gmp/manual/Algorithms.html#Algorithms
 
--SMQ
IP Logged

--SMQ

Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board