wu :: forums
« wu :: forums - Search in O(1) »

Welcome, Guest. Please Login or Register.
Jan 3rd, 2025, 12:06am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Eigenray, towr, william wu, Grimbal, Icarus, SMQ, ThudnBlunder)
   Search in O(1)
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Search in O(1)  (Read 764 times)
mad
Junior Member
**





   


Posts: 118
Search in O(1)  
« on: Mar 9th, 2008, 9:24am »
Quote Quote Modify Modify

Determine existence or non-existence of a number in a sorted list of N numbers where N numbers range over M, M>>N. N is very large to span multiple disks. Find it O(1).
IP Logged
mad
Junior Member
**





   


Posts: 118
Re: Search in O(1)  
« Reply #1 on: Mar 9th, 2008, 9:50am »
Quote Quote Modify Modify

Another Question-
 
Given an array of R,G and B balls, arrange them in groups with all R together, G together anb B together in one scan.
 
I thought of keeping the counts of all the three and building a new array based on this. Some better method, say inplace or more space efficient?
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Search in O(1)  
« Reply #2 on: Mar 9th, 2008, 1:44pm »
Quote Quote Modify Modify

on Mar 9th, 2008, 9:50am, mad wrote:
Given an array of R,G and B balls, arrange them in groups with all R together, G together anb B together in one scan.

http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_cs; action=display;num=1100111371
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Re: Search in O(1)  
« Reply #3 on: Mar 12th, 2008, 10:33am »
Quote Quote Modify Modify

on Mar 9th, 2008, 9:24am, mad wrote:
Determine existence or non-existence of a number in a sorted list of N numbers where N numbers range over M, M>>N. N is very large to span multiple disks. Find it O(1).

Woud N be O(1)?
IP Logged
Hippo
Uberpuzzler
*****





   


Gender: male
Posts: 919
Re: Search in O(1)  
« Reply #4 on: Mar 12th, 2008, 1:28pm »
Quote Quote Modify Modify

on Mar 9th, 2008, 9:24am, mad wrote:
Determine existence or non-existence of a number in a sorted list of N numbers where N numbers range over M, M>>N. N is very large to span multiple disks. Find it O(1).

 
I have problems with English ... are you asking ... is there a number on the list ... meaning is the list nonempty? Or are you looking for given number?
 
First can be answered in O(1), second requires at least log (N) comparisons (in the average case).
« Last Edit: Mar 12th, 2008, 1:29pm by Hippo » IP Logged
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