Arun wrote:

> On 11/17/06, Nik <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hi,
> >
> > I have an array in which elements are present .
> > The number of elements n <= 10^6 .
> > Now if i delete an element in the array, i want to update the
> > array by moving all the elements to the left. It is very slow
> > considering the size of element and i want to access the array
> > with new updated indexes (it needn't be o(1) it can be atmost O(logn))
> >
> > ex: 4 3 2 100
> > arr[2]=2;
> > once i access the index i delete the element,
> > So the new array should be 4 3 100, arr[2] should be now 100 etc.
> >
> > Can someone suggest me a good way to solve this problem
> >
> > Reg
> > Nik
> >
> >
> > >
> >
>> i suggest looking into implementation of erase() method of vector(STL). It
> does this for u. I wud guess they do it efficiently w/o shifting all the
> elements. (though my guess is it mite be moer of a systems hack than an
> algorithmic one).  if u find anything interesting , also let us know :)

Well erase is linear in the sense that it has to udpate all the indexes
right of it. I have seen the STL page but not sure about
implementation. Can it be done with maps.
If yes please show me how . I mean how to update the indexes once an
element is
deleted


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups-beta.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to