answersLogoWhite

0


Best Answer

There are several ways to either confirm that a given number is unique, or confirm that it is a duplicate of some number already on a list.

Unique on a short list

1) Compare the given number to each and every number on the list, one at a time, to see if the given number is already on the list. This is the best method for a short list of numbers.

Unique on a long list

2) If you are building a very long list of numbers, and you want to make sure that every number on the list is unique, sort the initial list of numbers and then do a binary search to see if the given number is already on the list. If it's not already there, then insert the new number in the appropriate place that keeps the list sorted.

3) If you already have a very long list of numbers, and you want to see if each and every number on that list is unique, sort the list and then scan the sorted list for duplicates (which will be consecutive). This is quick and easy to do with the "sort" and "uniq" command-line tools.

To generate a new list that only has the *unique* items in the original list (if any item is duplicated, that item is entirely left out of the second list):

cat in.txt | sort | uniq -u | tee uniques.txt

To generate a new list that lists only the *duplicated* items in the original list (but every item in the new list is unique in that new list, because it leaves out the second, third, etc. duplicates of the repeated items):

cat in.txt | sort | uniq -d | tee duplicates.txt

If that command doesn't print out anything, you can be sure that every item in the original list was unique.

To generate a new list that has both the *unique* items *and* the *duplicated* items -- i.e., *every* item in the original list exactly once (leaving out the second, third, etc. duplicates of repeated items), so every item in the new list is unique in that new list:

cat in.txt | sort -u | tee uniquified.txt

Universally unique

4) Sometimes you want a number that is globally unique, that no other human has ever seen before.

It's not possible to directly compare some given number with every number that any human has ever seen before If someone gives you a number, it's usually not possible to check after-the-fact if this is a unique number that only you two have seen, or if that someone gave you a copy of some old number that has been well-known by dozens of other people for decades.

However, it is possible to build a process that generates "new" numbers that are almost certainly unique, such that it is practically impossible that any human has ever seen it before.

(Such processes often involve "/dev/random", hardware random number generators, cryptographically secure pseudorandom number generators, or some combination of them).

Such processes are used to generate a universally unique identifier (UUID),

such as a globally unique identifier (GUID).

Generating such numbers is quick and easy to do with the "uuidgen" command-line tool (spelled "uuid_generate" on some systems).

uuidgen | tee unique_number.txt

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you check whether the number is unique number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

To check whether the given number is an Avogadro number or not?

45


What is check number?

A unique number using which any cheque can be tracked. The cheque number on any cheque issued by a single bank will always be unique


How do you check whether a number is a square number?

if it's square root is an integer, it is a square number.


Write a program By using if else statement to read a number and check whether it is positive or negative?

write a c++program by using if statement to read a number and check whether it is positive or negative


What does Stop Check NDC in the pharmacy mean?

It means to check the NDC number of the drug - every drug has a unique number that identifies what the drug is and which company made it.


Why doesn't Canada recognize the number 13?

Where do you get that idea? Who doesn't recognize the number 13? Better check whether Canada does, or does not, recognize this number, instead of just assuming such an improbable situation.Where do you get that idea? Who doesn't recognize the number 13? Better check whether Canada does, or does not, recognize this number, instead of just assuming such an improbable situation.Where do you get that idea? Who doesn't recognize the number 13? Better check whether Canada does, or does not, recognize this number, instead of just assuming such an improbable situation.Where do you get that idea? Who doesn't recognize the number 13? Better check whether Canada does, or does not, recognize this number, instead of just assuming such an improbable situation.


How do you find prime numbers between 2 and 70?

You can check each individual number, whether it is a prime number. For numbers below 100, it is enough to check whether they are divisible by 2, by 3, by 5, and by 7. If a number is divisible by none of these, it is a prime number.


Write an algorithm to check whether the given number is odd or even?

Type your answer here... i think we should first enter 1 number then check it


Does any whole number multiply to get 29?

29 is a prime number, meaning it has no smaller factors. For any number up to 120, to check whether it is prime or not, it is sufficient to check whether it is divisible by the first four prime numbers (2, 3, 5 and 7).


Algorithm to find prime numbers below ten?

Take each number in turn, call it "n", and check whether it has any factors f, such that 1 < f < n. If it doesn't, it is a prime number.Take each number in turn, call it "n", and check whether it has any factors f, such that 1 < f < n. If it doesn't, it is a prime number.Take each number in turn, call it "n", and check whether it has any factors f, such that 1 < f < n. If it doesn't, it is a prime number.Take each number in turn, call it "n", and check whether it has any factors f, such that 1 < f < n. If it doesn't, it is a prime number.


How do you find Number of prime numbers below certain number?

You just have to work out it,take each number below it and check whether it is prime or not.


Is zero a unique number?

Every number is a unique number.