wu :: forums
« wu :: forums - remove partial orderd elements from a array »

Welcome, Guest. Please Login or Register.
Jan 22nd, 2025, 8:45pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: ThudnBlunder, Grimbal, SMQ, towr, william wu, Eigenray, Icarus)
   remove partial orderd elements from a array
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: remove partial orderd elements from a array  (Read 521 times)
cuckoo
Junior Member
**





   


Gender: male
Posts: 57
remove partial orderd elements from a array  
« on: Aug 30th, 2007, 3:06am »
Quote Quote Modify Modify

In the past few months, I came across several similar problems on other forums. The problems can be generalized as follows:
Given an array of elements, say a[1..n], a partial order "<" is defined on the elements. If a[i]<a[j], then you must remove a[j] from the array. Your task is to remove all such a[j]'s so that for any i and j, neither a[i]<a[j] nor a[j]<a[i].
 
The partial order here may be interpreted as division "|", or set inclusion, etc.  
 
Especially, when the partial order is division "|", this problem is very similar to the sieve method for primes. The time complexity of sieve method is O(nloglog(n)).
 
My question is:  
(1)When the partial order is set inclusion, Can the above problem be solved in O(nlog(n)) time?
 
(2)Can the above problem be solved in O(nlog(n))  time regardless of the partial order?
 
 
« Last Edit: Aug 30th, 2007, 3:37am by cuckoo » IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: remove partial orderd elements from a array  
« Reply #1 on: Aug 30th, 2007, 4:30am »
Quote Quote Modify Modify

I think 1) would be difficult to do in O(n log(n) time.
consider
a[0]={2,3,4}
a[1]={1,3,4}
a[2]={1,2,4}
a[3]={1,2,3}
a[4]={1,2,3,4}
 
Even if you somehow know that a[4] is the only candidate the other can be a subset of, it would take O(n2) to check, unless perhaps you have some perfect incremental hash (i.e. the hash has a similar partial order that hash(X) < hash(Y) iff X < Y).
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
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