Hi all,
I need some advice in implementing a new ADT that has length of n and the following operations:
1) Init() : Initializes all n elements to 0. Can assume that this is the first one called and called only once.
2) Write(i,x): write value x to position i.
3) Read(i): Read the balue at location i.
4) MultiplyAll(y): Multiply ll elements by y, and this can be done many times to create accumulative effect. Cannot get y=0 (returns error)
5) ZeroAll: Zeroes all values in the ADT to 0.
So far so good - But here is the catch: Except the Init, all operations need to have O(1) complexity!
Any ideas?
Thank You,
Aviad
apines 116 Practically a Master Poster Featured Poster
Rashakil Fol 978 Super Senior Demiposter Team Colleague
~s.o.s~ commented: Good one.. ;-) +19
iamthwee commented: To counterbalance your star I'm sending you this. -2
Aia commented: I don't like your avatar, but still like you. - Aia :) +1
apines 116 Practically a Master Poster Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Rashakil Fol commented: This comment caused my post above to get a negative rep, so now you get one, too! -1
John A commented: Counterbalance! +12
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.