473,657 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compare 2 lists to find an equal or approximate match without doing N^2 iteration

1 New Member
I have two lists:
list1:[101,110,136]
list2:[101.04,264.5,37 9.9,466.4,629.6 ,724.4,799.8,91 4.3]

iterate over list1:
compare each element in this list with the elements in the list2,
if there is a number encountered in the 2nd list which is an exact match or an approximate match to the element in list1 then output that match

Note: I want to avoid the N^2 iteration strictly as I want to do it as efficiently as possible; also in all cases I sort both the lists hence both are in ascending order always.

Output should be: 101 and 101.04
Nov 21 '13 #1
2 1854
anmoluppal
7 New Member
hmmmmm ..... I have thought of an algorithm that could be very efficient but it would take some time to develop a working code for that ... I hope you have enough time ... would let you know ASAP if that algo would be implemented efficiently by me .....
Nov 21 '13 #2
dwblas
626 Recognized Expert Contributor
which is an exact match or an approximate match
For an exact match, using sets and subset is the most efficient way. You do not define "approximat e" though so there is no way to go further.
Dec 6 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3619
by: AA Arens | last post by:
When I place a record serch utility (vos the button placement wizzrd), I discovered that the Match setting is "Whole Field" by default. How to make "Any Part Of Field" default?
3
4993
by: Andreas Klemt | last post by:
Hello, how can I clear all ViewStates from a WebUserControl without doing a PostBack ? Thanks in advance, Andreas
2
14634
by: UJ | last post by:
Is there a way with a asp:checkbox to run a JavaScript to display/hide text/input on the screen without doing a postback? I also need to be able to access the stuff at the server so I need to have run=server with it. TIA - Jeff.
3
3841
by: Saber | last post by:
There are some Images (System.Drawing.Image) with same widths and heights, I want to find if 2 images are equal. How can I do it? The following code always returns false: If img1.Equals(img2) Then MsgBox("ok!") Else MsgBox("wrong!")
3
4494
by: sunmat | last post by:
To find number of character without space using java Example: String = prabu sun No. of char =8 plz send me code
2
7216
by: Slippy27 | last post by:
I'm trying to modify a find/replace script which iterates through a file A and makes replacements defined in a csv file B. My original goal was to change any line in file A containing a search string (in whole or as a substring) defined in file B. File B contains both the search string and the string it should be changed into. Example file A whippy slippy ippy slippy snoob flop bloppy
6
25217
matthardwick
by: matthardwick | last post by:
Is there a way to make the find box (Ctrl+F) default to match "Any part of field" instead of "Whole field". Thanks in advance. Matt.
7
9850
by: shapper | last post by:
Hello, I have two lists, A and B, of a same class which has two properties: ID and Name A items have only the Name defined. B items have the ID and the Name defined. I want to create a new list, C (ID and Name), with the items in A
2
1720
by: stevenblanc | last post by:
As in the title, Is it possible to create a combobox that has a list visibly wider than itself, i.e. displaying a list with all columns which is wider than the box itself without the need for scrollbars. If it is, how would one accomplish this task?
23
14624
by: tetsuo2030 | last post by:
Hi all, I have two fields in a query: and . is a list of comma-separated paragraph numbers (like 1.0, 1.1, 1.1.2, etc); is just "1.0" or "1.1.2" or the like. I wanted to create a third field called that would scan through to find where it equals . I tried this: Paragraph Check: InStr(,) This was useful because if didn't show up in it gave me gave the value "0"; otherwise, it gave me the position of the (6 or 20 or 29),...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.