LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-25-2005, 07:05 AM   #1
niteshadw
Member
 
Registered: Sep 2002
Distribution: CentOS
Posts: 170

Rep: Reputation: 15
binary seach; vector instead of an array


Is it possible to do a binary seach by using a vector instead of an array? I found something here http://www.roguewave.com/support/doc...ibug/14-4.html but it does not seem to want to compile. I have two vectors and I want to see if any value in vec1 is in vec2, if it is, then copy that item into another vector. I think that is the most efficient way?

Any one would be kind enough to show where I could find a working code for binary seach and vectors or is there a better way to achieve what I'm trying..thanks

[edit]

The search within the vector class, its a binary search?

Last edited by niteshadw; 08-25-2005 at 09:00 AM.
 
Old 08-25-2005, 09:03 AM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
yes, it *is* possible.

here's a code snippet: jonaskoelker.homeunix.org/~jonas/test.cc

you could also use set_intersection (iirc); look in your favorite STL reference.

hth --Jonas
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
representation of binary tree using array sajith Programming 3 10-06-2005 10:59 PM
can i modify int 80 vector to a user-defined vector qqrilxk Linux - Security 1 03-03-2005 08:46 PM
why dont seach results show search string? Fascistchicken LQ Suggestions & Feedback 6 04-25-2004 02:29 PM
php mysql databate seach program set up spoody_goon Programming 2 11-21-2003 06:02 PM
Snort... my seach continue... TheIrish Linux - Security 4 11-18-2003 04:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration