Questions tagged [comparison]

Questions about data comparison and efficient ways to accomplish it.

Filter by
Sorted by
Tagged with
-4 votes
3 answers
147 views

How to identify whether or not 2 pieces of text are identical? [closed]

Let's say I was to create a scraper. At some point I'll need to come up with algorithm of identifing whether or not a piece of a newly scraped text matches the one that's already in the DB. How would ...
user avatar
2 votes
2 answers
293 views

Isn't data migration a major benefit of MongoDB compared to the commonly used relational databases?

I was reading an old answer which was recently updated, and noticed that the author doesn't quote the simplicity of data migration as a benefit of MongoDB. I always thought that the major benefit of a ...
user avatar
1 vote
4 answers
667 views

Can writing Object-Orientated Code in a Functional style improve performance?

Given a scenario where you have consecutive setters or a series of events where an object is modified, can it be more performant to instead write code in a way where a new state is returned rather ...
user avatar
  • 129
0 votes
4 answers
229 views

Language design : use equals symbol = both for affectation and comparison, like in MySQL

I'm currently designing a database query language and I came to wonder what should be the best syntax for the comparison operator. Most modern languages use ==, but amongst the database languages ...
user avatar
  • 241
9 votes
4 answers
2k views

"REST Vs GraphQL" is it a correct comparison?

I saw in many sites that compare REST with GraphQL. after investigating this concern (actually my concern) that, "is it a correct comparison?", I being more confused. Since the REST has a different ...
user avatar
  • 107
0 votes
1 answer
56 views

Objectreference vs Equality [closed]

While coding I stumbled upon something like this (extremely simplified example): public bool Func() { Object[] array = new Object[] {false, false}; return array[0] != array[1]; } I was ...
user avatar
2 votes
4 answers
128 views

Date comparison with the last second of a day

Would you consider WHERE SomeDate <= '2018-01-01 23:59:59' instead of WHERE SomeDate < '2018-01-02' When the intention is that SomeDate goes no further then 2018-01-01 a code smell and if ...
user avatar
  • 129
1 vote
1 answer
88 views

Simulating Comparison Without Using Comparison Primitives

In the same way that you can simulate the if statement and functions, I am wondering if there is a way to simulate the comparison operators ==, !=, >, >=, <, <=. For example, in ...
user avatar
  • 2,412
-4 votes
1 answer
549 views

TIOBE Index: why c++ is in 3rd place and C is having more land in the last year?

Searching for c++ ranking on the TIOBE index, I was stumped to see that C is in front of C++, and from 2017, C took a leap. Could someone explain why?
user avatar
2 votes
2 answers
4k views

Proving Two Zip file are identical

I migrated some files from one Version Control System to another. I have to prove that content are identical (between source and destination, denote 1 , 2). There are a few zips files (lets call them ...
user avatar
12 votes
2 answers
2k views

Is the IComparable interface outdated/"harmful"?

IComparable only works one way Let's say you have a Employee class. In one view, you want to show all Employees sorted by name - in another, by address. How are you going to achieve that? Not with ...
user avatar
  • 2,598
1 vote
2 answers
325 views

Is comparing "dollar-hours" for running a specific piece of code practical as an estimate of rented system performance?

Background: there'a a gazillion types of virtual machines in Microsoft Azure each having different performance and price. Such virtual machines are paid per hour. The goal is to decide how to get "the ...
user avatar
  • 4,309
1 vote
1 answer
673 views

Best approach for name similarity

As part of validation, we perform name similarity check and allow only if the threshold is reached. I got some help from StackOverflow regarding the implementation and finally implemented JaroWinkler ...
user avatar
  • 169
-1 votes
2 answers
215 views

Why in Tournament Sorting do we neglect the number of comparisons to find the Minimum?

Here the professor said that, Tournament sort needs (n-1) + 2(n-1)logn comparisons. {Where (n-1) for calculating Maximum or say creating Tournament structure and 2(n-1)logn for other elements to sort}...
user avatar
  • 47
18 votes
1 answer
3k views

How does integer comparison work internally?

E.g. when comparing two integers as follows in a C-like language: if (3 > 2) { // do something } How is the judgement whether 3 is greater than 2 (true) or not (false) made internally?
user avatar
  • 307
1 vote
2 answers
1k views

What are the most idiomatic abbreviations for comparison operators [closed]

I am wondering what the most idiomatic text abbreviations for comparison operators are. I need to build a custom enum with them, so I cannot use their symbols. To me personally, these seem idiomatic: ...
user avatar
  • 184
1 vote
0 answers
524 views

I want to write an application to compare files, similar to WinMerge. I'm not sure how to design it, though

My current project is to implement a kind of WinMerge clone to compare two files. I am using C++ with the Win32-API (WTL, ATL, that stuff), and I already designed an UI for this. However, I am now ...
user avatar
1 vote
1 answer
85 views

How to analyse user input and determine if it (kind of) matches an answer

I'm working on a quiz system that will allow users to enter text as an answer. The question could be something simple to start with, looking for a short phrase, or a select few words as the "correct" ...
user avatar
  • 133
5 votes
4 answers
7k views

Four-way XML comparison in C#

I have 4 XML files: A, B, C, and D. I want to know if the difference between A and B is the same as the difference between C and D. The XML files are serializations of the same .NET object; one of ...
user avatar
1 vote
4 answers
439 views

Comparing objects with tolerance

The following code says that c1 == c2 and c2 == c3, but c1 != c3. TOL = 0.11 class C: def __init__(self, x): self.x = x def __eq__(self, other): return abs(self.x - other.x) ...
user avatar
  • 115
0 votes
0 answers
57 views

Is there some reason into allowing assignations in a conditional? [duplicate]

I bet I'm not the only one here that has had problems with something like this: you want to check something in a language that has the == operator for checking equality and instead you do something ...
user avatar
1 vote
1 answer
179 views

How do travel search engines combine flights

I'm curious about how the flight/train search engines combine the results from multiple sources. For example, let's say I'm asking to go from London to Paris, and let's assume there are no direct ...
user avatar
2 votes
2 answers
481 views

Algorithm for lines comparison

I'm working on the import of land-use data into Openstreetmap. Unfortunately I've encountered a problem that has delayed my time table. Take a look at the picture below: the red line is the main road ...
user avatar
  • 147
0 votes
1 answer
211 views

Developing a simple HTML exercises with JavaScript [closed]

I'm developing a website with some simple HTML exercises (like the ones in Codeschool and Codacademy), and now I'm stuck at the correction phase, how can I compare two HTML strings and decide if the ...
user avatar
43 votes
10 answers
8k views

Why do most mainstream languages not support "x < y < z" syntax for 3-way Boolean comparisons?

If I want to compare two numbers (or other well-ordered entities), I would do so with x < y. If I want to compare three of them, the high-school algebra student will suggest trying x < y < z....
user avatar
  • 647
0 votes
3 answers
286 views

How to effectively compare the (almost) same code which has been auto-formatted?

I am trying to infer the differences between two projects, however so far it has been really painful, because one of the parties has done auto-formatting on the code. Basically, this makes a merging ...
user avatar
0 votes
1 answer
18 views

Comparing articles from various web-stores

Today I had the idea to write a program that compares the prizes between different web-stores. The key question I am asking myself is how to find (with a high probability) the same article on another ...
user avatar
  • 113
7 votes
4 answers
17k views

Avoiding Division by Zero Using Float Comparison

Source code analyzers (like SonarQube) complain about float (or double) equality comparisons because equality is a tricky thing with floats; the values compared can be the results of computations ...
user avatar
  • 231
7 votes
2 answers
1k views

Efficient algorithm to merge n successive sorted arrays in place

I am developing an in-place sorting algorithm that leaves the array into a state where it is basically a succession of sorted subsequences of any size (most are bigger than log2(size(array))); then it ...
user avatar
  • 1,716
0 votes
1 answer
1k views

Comparison Function Returns True or False

In my python CS class at school, we were given a true or false question as follows. A comparison function returns either True or False. When originally answering I thought about two things. First,...
user avatar
26 votes
5 answers
2k views

Could an instance be equal to some other instance of a more specific type?

I've read this article: How to Write an Equality Method in Java. Basically, it provides a solution for an equals() method that supports inheritance: Point2D twoD = new Point2D(10, 20); Point3D ...
user avatar
  • 822
0 votes
3 answers
7k views

Functional programming: Compare all items in an array

In functional programming, how do I do an equality comparison of all items in an array? I have an array of items that I want to compare, for example for equality. Is it possible to use a fold (also ...
user avatar
  • 137
2 votes
0 answers
398 views

Algorithm to maximize pairwise comparisons using transitive property

I'm looking for some direction on building an algorithm that will maximize the number of pairwise comparisons of objects in a set using transitivity. To explain in detail: Suppose there are x ...
user avatar
4 votes
3 answers
710 views

Determine frequency-range that matches closest to input list of frequencies

Since this question is not about "code not working", I'm asking my first question here instead of StackOverflow. Inform me if any required information is missing from the question. Setup: I have two ...
user avatar
  • 543
1 vote
2 answers
153 views

Multi-pattern matching

I have a given byte array in C and I need to match it against several byte arrays and return true if there is any match. I can make various memcmp's but I feel that it is very inefficient. Do you ...
user avatar
0 votes
1 answer
255 views

Should a comparison method ever return the same type back as it's comparing?

First, this is homework, but no, I'm not asking for anyone to do any code for me. My course start date isn't for another month (it's online), so I can't ask for clarification. I thought I'd see if ...
user avatar
5 votes
4 answers
941 views

Legitimate cases of having .equals() behaving inconsistently with .compareTo()?

Java documentation says it's "strongly recommended" to have them behaving consistently. But are there legitimate cases of java/c#/python/etc Object.equals() method behaving inconsistently with the ...
user avatar
  • 822
11 votes
4 answers
51k views

List comparing techniques for faster performance

I need to cross names from two lists, and find all occurrences of one name in the other. The lists are too big, one have 50k elements and the other 400k. For a small list I would use two foreach ...
user avatar
  • 277
0 votes
0 answers
1k views

Compare names and the use of Levenshtein's algorithm

I need to cross names from two lists. What is the best away to compare the names? As you may expect, in one list we can have the complete name, on the other just the first and last. Besides that, ...
user avatar
  • 277
0 votes
3 answers
805 views

Is JavaScript fail-safe?

I was compiling a list of comparison of top 10 programming languages (JavaScript included). I was doing it from this Wikipedia page. However, in the third table (Failsafe I/O), there is no row for ...
user avatar
2 votes
1 answer
53 views

Comparing path strings against list of rules

I am trying to find a way to enhance a filtering algorithm. I am developing a backup software that enables users to specify custom filters to exclude unwanted files/directories. Currently when trying ...
user avatar
5 votes
4 answers
2k views

Why are return values from compare functions in many languages defined loosely?

Many languages define that compare functions should return ANY negative value, zero, or ANY positive value. Is there some reason that it shouldn't be clearly defined as -1 0 and 1? Does a wide range ...
user avatar
  • 163
-2 votes
1 answer
309 views

Why are mostly 9999, 99999.... are used for making comparisons [closed]

I (I am sure everyone else also) have always seen comparisons of some value to 999 or 9999 .... etc. for e.g.: in CSS z-index: 9999 or some times str.length < 99999 I wonder if there is some ...
user avatar
25 votes
2 answers
25k views

Algorithm to merge two sorted arrays with minimum number of comparisons

Given are two sorted arrays a, b of type T with size n and m. I am looking for an algorithm that merges the two arrays into a new array (of maximum size n+m). If you have a cheap comparison ...
user avatar
6 votes
5 answers
2k views

Algorithm to test file equivalence

I'm writing a program that needs to test if a file is equivalent to one or more other files. To accomplish this, every time we see a new file we stat the file and get the size. We use the size as a ...
user avatar
0 votes
2 answers
1k views

Comparing doubles [duplicate]

I need to compare to double variables like this if (distance <= radius) both distance and radius are doubles and I remember in class how to use epsilon comparisons for checking equality but how ...
user avatar
7 votes
2 answers
1k views

Is there any language-agnostic specification for "String Natural Sorting Order"

As I painfully try to find a good natural sorting algorithm written in JavaScript I then stumble upon a bunch of different implementations, & interesting blog posts & answers on Stack Overflow....
user avatar
  • 181
0 votes
2 answers
288 views

Finding metrics for development time in different languages [closed]

I'm trying to determine if a language I'm investigating (Groovy) is better for developing enterprise applications than our current language (Java). Specifically I'm trying to figure out if it will ...
user avatar
  • 231
0 votes
1 answer
517 views

comparison of an unsigned variable to 0

When I execute the following loop : unsigned m; for( m = 10; m >= 0; --m ){ printf("%d\n",m); } the loop doesn't stop at m==0, it keeps executing interminably, so I thought that ...
user avatar
  • 145
1 vote
2 answers
2k views

Comparing two software versions in C#

I´m working on a mod update checker for minecraft, but there is a big problem: The modders and online database that I´m using for update checks has no standard software versions e.g.: Local: rv0-...
user avatar