In: Computer Science
What will the value of A represent at the end
of execution of the given procedure on the “Paragraph Words”
dataset?
Step 1. Arrange all cards in a single pile called Pile 1
Step 2. Maintain two variables A, B and initialize them
to 0
Step 3. If Pile 1 is empty then stop the iteration
Step 4. Read the top card in Pile 1
Step 5. Add Letter count to variable B
Step 6. If the word does not end with a full stop then execute step 9
Step 7. If the word ends with a full stop and B > A then store B in A
Step 8. Reset the variable B to 0
Step 9. Move the current card to another pile called Pile 2 and repeat from step 3
Select answer from the following options:
1. Length of the shortest sentence based on the number of words
2. Length of the longest sentence based on the number of words
3. Length of the longest sentence based on the number of characters
4. Length of the shortest sentence based on the number of characters
5. None of the above
This procedure finds the Length of the longest paragraph based on the number of characters and paragraph ends with full stop. (lettet count = number of characters in a card)
Ans:: None of the above.
If we Assume Each card conatains one sentence and each valid sentence ends with full stop then only the answer will be 3. Length of the longest sentence based on the number of characters
(Assume Each card conatains one sentence and each valid sentence ends with full stop)
If the card contains
Explanation::
Pile1 =[ card_1,card_2,………card_n]
A=B=0
LOOP:: Repeat the following steps if Pile1_Not_Empty, else goto STOP
{
Read top_card (note:: first iteration it is card1,next iteration card_2 and so on)
B=B+ letter_count(top_card) =0+letter_count(top_card)=letter_count(top_card)
.i.e, stores number of letters/characters in card
If(word_end_with_fullstop AND B > A), do the following assignment
{
A=B; ( Note:: if the current top_card contains more letters than
previous card, then its count, letter_count(top_card) is stored in A.
i.e A contains highest letter count)
}
B=0
Move top_card to Pile2 (Next card becomes top_card. In each iteration it will be
card_2, card_3 and so on)
jump to LOOP
}
STOP :: stop