In-place list manipulation
- From: "Aki Tuomi" <cmouse@xxxxxxxxxxx>
- Date: Thu, 22 Nov 2007 15:30:51 +0200
When doing mergesort in place, I have ran into a following problem:
How to perform in-place interleave during merge without need of auxilliary
list or array?
I have two sets of indexes: a.start, a.stop and b.start and b.stop. These
contain start and stop indexes in the list where the data is. My question
is, how do I do merge the two into the list in-place?
Example:
List = {1,3,2,5,4,6,7,8,9}
a.start = 1
a.stop = 2
b.start = 3
b.stop = 4
a = {3,2}
b = {5,4}
merge(a,b,List)
List = {1,2,3,4,5,6,7,8,9}
I have solved this now by copying the two segments into temporary arrays and
then copy data back from there, but it does not really feel right. Any
ideas?
Aki Tuomi
.
- Follow-Ups:
- Re: In-place list manipulation
- From: CBFalconer
- Re: In-place list manipulation
- From: jehugaleahsa@xxxxxxxxx
- Re: In-place list manipulation
- From: Aki Tuomi
- Re: In-place list manipulation
- From: Gene
- Re: In-place list manipulation
- From: Richard Harter
- Re: In-place list manipulation
- Prev by Date: Re: Places to purchase PowerBASIC?
- Next by Date: Question on binary search Trie
- Previous by thread: Re: how to get data accurately from UDP
- Next by thread: Re: In-place list manipulation
- Index(es):
Relevant Pages
|
|