C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 13th, 2004, 07:30 PM
playlife playlife is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 8 playlife User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 42 m
Reputation Power: 0
Comparing 2 Arrays (unconventional)

Hi all. Firstly many thanks for all those who have posted, some great material on this forum.

My current problem is comparing two arrays, however it has a bit of a difference to the 'standard' array comparison problem.


E.g.:
Array A has 400 elements. Each element contains a range of values that a secondary array must be evaluated to (in other words, Array A is the baseline).

value of array_A[0] element is defined as a value in the range [1996, 4095].
value of array_A[1] element is defined as a value in the range [1, 31].

So on and so forth with some 400 elements.

The objective is to compare Array B to the Array A paramters and to determine whether the corresponding element is within the given range.

mathematically, if (1995 < array_B[0] < 4096) then = true.



I do have some code for it, but it is extremely inefficient and simply inappropriate to use for arrays of over 1000 elements.
The range parameters must also be easily accessible for modification in the future, so the range definition for the required paramter should not be buried in xxx lines of code (preferably of course).

Reply With Quote
  #2  
Old December 13th, 2004, 07:48 PM
fisch's Avatar
fisch fisch is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2004
Location: Frostbite capital of the world
Posts: 542 fisch User rank is Lance Corporal (50 - 100 Reputation Level)fisch User rank is Lance Corporal (50 - 100 Reputation Level)fisch User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 16 h 58 m 34 sec
Reputation Power: 10
throw up the code, i don't understand what the problem would be. I'd just create Array_A as a 2-D array.

Array_A[400][2] where:
Array_A[i][0]=min range value;
Array_A[i][1]=max range value;

where do you think the inefficiency is?

Reply With Quote
  #3  
Old December 13th, 2004, 07:50 PM
DaWei_M's Avatar
DaWei_M DaWei_M is offline
Renaissance Redneck
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
Posts: 8,509 DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Weeks 17 h 53 m 58 sec
Warnings Level: 20
Number of bans: 3
Reputation Power: 3268
Quote:
mathematically, if (1995 < array_B[0] < 4096) then = true.

That's a very good start, put it in a loop. The question in my mind is how you have a "range" specified in the one element. Text as in "1995-4095", or what?
__________________
Functionality rules and clarity matters; if you can work a little elegance in there, you're stylin'.
If you can't spell "u", "ur", and "ne1", why would I hire you? 300 baud modem? Forget I mentioned it.
DaWei on Pointers Politically Incorrect.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Comparing 2 Arrays (unconventional)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap