Suitable Data Structure?
- From: "J.M." <jm_jm@xxxxxx>
- Date: Fri, 02 Dec 2005 10:58:15 +0100
Perhaps this is slightly off-topic: if it is, could someone suggest a better
group?
I have the following problem, and would certainly appreciate some help. I
need to find a suitable data structure for a vector v of dimension n to
implement the following algorithm effectively:
v=0
for i=1..n
for j=1..m
Update j components of v: v_(j(i)) = v_(j(i))+d_(j(i)) (1)
end for j
determine I such that v_I = max(v_i: i=1,..n). (2)
v_I =0
end for i
The difficulty is the following: The precise components j(i) of v that will
be updated in (1) and the values of d_(j(i)) are unknown in advance. (They
are calculated in the i-loop elsewhere.) In any case, n is quite large
(often n>10^5), whereas m is usually quite small (m<100).
Simply selecting the largest element in (2) requires O(n) operations, for a
total of O(n^2) operations in the entire algorithm, which is too high for
my application. Keeping v sorted and updating the order of v after every
update seems to be too expensive if a linear data structure is used. The
actual amount of work needed would also be too unpredictable. Ideally, a
binary tree could be used to keep the elements in order, but to my
knowledge, once an element is inserted in the tree, it cannot be updated,
so this is not suitable either. Essentially, I need an algorithm that
requires significantly less than O(n^2) operations. Ideal would be, of
course, O(n*log n), which could be obtained if a binary tree could be used.
Any ideas?
For the sake of completeness, I should add that all d_(j(i)) are positive,
so that all components of v are also positive. Furthermore, once v_I has
been selected and set to zero, it will definitely not be updated and can be
discarded.
Thanks in advance
Jan
.
- Follow-Ups:
- Re: Suitable Data Structure?
- From: Martin Eisenberg
- Re: Suitable Data Structure?
- From: John Herman
- Re: Suitable Data Structure?
- From: Gordon Sande
- Re: Suitable Data Structure?
- From: Jean-Claude Arbaut
- Re: Suitable Data Structure?
- Prev by Date: Re: GSS new high performance sparse solver
- Next by Date: Re: Suitable Data Structure?
- Previous by thread: Probability: one number larger than other
- Next by thread: Re: Suitable Data Structure?
- Index(es):
Relevant Pages
|
Loading