Category: Algorithm

  • Finding Rank of a Word: With Repetition

    Finding Rank of a Word: With Repetition

    Rank of word
    Rank of a word

    In the previous tutorial, we learn how to find the rank of a word, if the letters are having no repetition. Now lets learn how to find the rank of word, if the letters in a word having repetition.

    Before proceeding to the tutorial: we should know, how to calculate the total number of words can be formed using letters of a word is the letters are repeating in nature.

    Like how many words can be formed using letters of INDIA. In letter “INDIA” there are 2 I and no other letter is repeating. So the number of words that can form using letter of INDIA will be 5 ! / 2 ! = 60.

    Now we may proceed with new learning.

    Algorithm

    1. First take that word which we have to find the rank and the letters are repeating in nature. I will take “BOMBAY.”

    2. Now arrange the letter of ” BOMBAY ” in alphabetical order. Now they are “ABBMOY”.

    3. Pickup first letter from “ABBMOY” that’s “A”. Now compare “A” from “BOMBAY”. Does the letter “A” in the first we want? NO. Now how many words can be made if we extract “A” from “ABBMOY”.

    A = 5! / 2! = 60

    Now proceed to the next.

    4. Pickup second letter from “ABBMOY” that’s “B”. Now compare “B” from “BOMBAY”. Does the letter “B” in the first we want? Yes. Now fix the letter “B”.

    [ B ]

    Then go to once again on the first letter of “ABBMOY”. Does “A” we want? NO. Then write down how many words can be made with starting [ B ] A

    [ B ] A = 4! = 24

    5. Repeat the process until we get the letter which we want after B in the word “BOMBAY”.

    [ B ] B = 4! = 24
    [ B ] M = 4! = 24

    [ B ] O. “O” we want. So fix this and get back to the starting.

    6. Does we want now [ B O ] A? NO. So write down once again.

    [ B O ] A = 3! = 6
    [ B O ] B = 3! = 6

    [ B O ] M. “M” we want now. So fix this too. And get back to the starting.

    7. Does we want [ B O M ] A? No. So write down once again.

    [ B O M ] A = 2! = 2

    [ B O M] B. “B” we want. So fix this too. And get back to starting. We see “A” also we want now. So fix this too. And the last letter is “Y” We also want this. So we reach to the end. Now we can write.

    [ B O M B A Y ] = 1.

     

    8. Now add the entire sum which we earn.
    That’s 60 + 24 +24 + 24 + 6 + 6 + 2 + 1 = 147. That’s the answer.

    Now for Word “INDIA

    1. [ A D I I N ]
    2. A = 4! / 2! = 12
    2. D = 4! / 2! = 12
    3. [ I ] A = 3! = 6
    4. [ I ] D = 3! = 6
    5. [ I ] I = 3! = 6
    6. [ I N ] A = 2! =2
    7. [ I N D ] I A = 1.

    Now add all.

    12 + 12 + 6 + 6 + 6 + 2 + 1 = 45.

    So that’s the answer. Congratulation now you are able to find RANK of any word if its letters are repeating in nature.

  • Finding Rank of a Word. (No Repetition)

    Finding Rank of a Word. (No Repetition)

    Finding the rank of a word
    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