Categories: AlgorithmMathematics

Finding Rank of a Word. (No Repetition)

Finding the rank of a word

Lets first, we should know what is the RANK of a word?

Rank of a word is the position of that word from the arrangement of letters of that given word in dictionary order. Lets see an example…this can help more in understanding the RANK of a word. Its really interesting to find rank of Word.

 

Lets took word “RANK

  1. How many words, can be created  using the letters of word RANK? Ans: The number of characters in word “RANK” is 4. So it will be 4! = 4*3*2*1 = 24.
  2. Now if we arrange all the 24 words formed by the letters of “RANK” in dictionary order.
  3. Then at what postion the the word “RANK” will exist?
  4. That particular position of the word, will be the rank of word “RANK”.

Algorithm 1st:

  1. Take a word which we have to find the rank. I will take “SUNIL”.
  2. Now arrange the letter of “SUNIL” in alphabatical order.
    It will be. “I L N S U“.
  3. Now take the first letter. Its “I”. Now check, Is the letter “I” is the first letter of “SUNIL”? No.
    So the no. of word found can be formed with I will be 4!. I = 4! = 24
  4. Now go for the second letter. Its “L”. Now check once again is this letter we want in first? No.
    So. the no. of words can be formed using “L” at first will be 4!.
    L = 4! = 24
  5. Now go for “N”. Is this we want? No. Write down the number of words can be formed using word. “N” is once again 4!N = 4! = 24
  6. Now go for “S”. Is this is what we want? Yes. Now cut the letter from the alphabetically ordered word. it will be now. “I L N S U”
    Write S and check the word once again in the list.
    Is we want SI? No. so the number of words can be formed using SI at first will be. 3! [S] : I -> 3! = 6
  7. Go for L. is we want SL? No. so it will be 3!. [S] : L ->  3! = 6
  8. Go for N. is we want SN? No. [S] : N ->  3!  =  6
  9. Go for SU. Is this we want? Yes cut the word U from the list and then it will be “I L N S U.
    Now Go for I. is we want SUI? no. so the no of word can be formed which starts from SUI will be 2! Now [SU] : I -> 2! = 2
  10. Now go for L. is we want SUL. No. so the no. of words. can be formed. SUL will be 2!. [SU] : L -> 2! = 2
  11. Now go for N. Is we want SUN? Yes now cut that letter. and this will be “I L N S U Is we want SUNI yes. cut that word. Then only one letter will be left.”L”.
  12. Now go for L. Is we want SUNIL yes. SUNIL words having only 1!.
  13. [SUN][I][L] = 1! = 1

Now add the whole numbers we get. The sum will be.

24 + 24 + 24 + 6 + 6 + 6 + 2 + 2 + 1 = 95.

So the word SUNIL will be at 95th position if we form the whole words that can be created using the letters of SUNIL arranged in dictionary order.

Lets check the rank of SURYA now.

  1. A R S U Y//Arranged in Alphabatical Order.
  2. A = 4! = 24 // Is A We want? No.
  3. R = 4! = 24// Is R? No.
  4. [S]:A-> 3! = 6 // Is S? Yes. Cut the word S from that list. And move to next letter. Is SA? No.
  5. [S]:R-> 3! = 6 // IS SR? No.
  6. [SU]:A-> 2! =2 //Is SU? Yes. Cut the word U from that list. And move to next letter. IS SUA? No.
  7. [SUR]:A-> 1! = 1 // Is SUR? Yes. Cut the word A From that list.
  8. [SURY][A] = 1!= 1 //Is SURY? Yes. Cut Y. Only one letter is now left “A” That will be last. Is “SURYA”? Yes.

Now sum all that. 24 + 24 + 6 + 6 + 2 + 1 + 1 = 64.

Shortcut Method to Find the Rank of WORD
( No Repetition )

Algorithm 2nd:

Take the Word “SURYA” once again.

  1. A R S U Y // Alphabatcal Order
  2. 2 * ( 4 ! ) = 48// Search for S. Remove that word from the list and see how many letter before S? 2 letter.
  3. 2 * ( 3 ! )  = 12 // Search for U. Remove that letter and count the letters before U now. Its 2.
  4. 1 * ( 2 ! )  = 2 // Search for R. Remove that letter and count the letters before R. Its 1.
  5. 1 * ( 1 ! )  =  1// Search for Y. Remove that letter and count the letter before Y. Its 1.
  6. Add the whole numbers. and add 1 for last letter A.
  7. Sum: 48 + 12+ 2 + 1 + 1 = 64.

That’s all. So here we see how to find the rank of word if the word has no repetition. In the next post I will tell how to find the rank of a word if the word had repetition like in the case of INDIA. “I” is repeated  2 times.

Edit: Link of Finding Rank in Repetition

Surya

Living in permanent beta mode: Learning, Improving & evolving. SPECIALTIES: Web Application Development, Digital Media, E-Commerce Solutions, SEO, CRM Solutions, Open Source Technologies, System Administration ( Linux ), VOIP Solutions, Cloud Computing, Web Security.

View Comments

Share
Published by
Surya

Recent Posts

How to get the all the database and table sizes of MySQL or MariaDB?

If you are working with MySQL or MariaDB web server, sooner or later you will…

7 years ago

How to set or change default text editor for crontab in Linux?

To edit the crontab entries you use crontab -e. The command will check for the…

7 years ago

How to install Comodo SSL certificate with NGNIX web server?

Installation method for COMODO SSL Certificate If you have generated the CSR and purchased or…

7 years ago

How to give access to specific users to specific buckets on AWS S3

In AWS S3, you might want to provide the access to selected users to selected…

7 years ago

How to add or change the password (passphrase) of OpenSSH key?

It's possible you have earlier generated a ssh key without password/ passphrase. Later you found…

7 years ago

How to find files on linux OS ( distributions )

If you are working on Linux OS, finding files effectively always a tricky part. Like…

7 years ago