SECTION 02 / 13

Search within ordered words and sentences

3 min read
On this page 4 headings

“First verb in the third sentence” is an order-sensitive question. Unlike counting or finding a maximum value, it cannot be answered correctly after randomly shuffling the word cards.

In the original word-card order, the third sentence begins with He, followed by considered: its first verb.
In the original word-card order, the third sentence begins with He, followed by considered: its first verb.
YOUR COURSE DATA · TRY IT HERE

Find the first verb in the third sentence

Use the supplied 65 word cards. No download or coding is needed.

READY TO START

A pile of 65 cards

Start with the first card. Read its fields, do one small action, then move on.

What we remember

Read
0

Nothing has been read yet. Choose Next card to begin.

Look through all 65 original records
ItPronoun · 2 letters
SerialNumber
0
Word
It
PartOfSpeech
Pronoun
LetterCount
2
wasVerb · 3 letters
SerialNumber
1
Word
was
PartOfSpeech
Verb
LetterCount
3
MondayNoun · 6 letters
SerialNumber
2
Word
Monday
PartOfSpeech
Noun
LetterCount
6
morning.Noun · 7 letters
SerialNumber
3
Word
morning.
PartOfSpeech
Noun
LetterCount
7
SwaminathanNoun · 11 letters
SerialNumber
4
Word
Swaminathan
PartOfSpeech
Noun
LetterCount
11
wasVerb · 3 letters
SerialNumber
5
Word
was
PartOfSpeech
Verb
LetterCount
3
reluctantAdjective · 9 letters
SerialNumber
6
Word
reluctant
PartOfSpeech
Adjective
LetterCount
9
toPreposition · 2 letters
SerialNumber
7
Word
to
PartOfSpeech
Preposition
LetterCount
2
openVerb · 4 letters
SerialNumber
8
Word
open
PartOfSpeech
Verb
LetterCount
4
hisPronoun · 3 letters
SerialNumber
9
Word
his
PartOfSpeech
Pronoun
LetterCount
3
eyes.Noun · 4 letters
SerialNumber
10
Word
eyes.
PartOfSpeech
Noun
LetterCount
4
HePronoun · 2 letters
SerialNumber
11
Word
He
PartOfSpeech
Pronoun
LetterCount
2
consideredVerb · 10 letters
SerialNumber
12
Word
considered
PartOfSpeech
Verb
LetterCount
10
MondayNoun · 6 letters
SerialNumber
13
Word
Monday
PartOfSpeech
Noun
LetterCount
6
speciallyAdverb · 9 letters
SerialNumber
14
Word
specially
PartOfSpeech
Adverb
LetterCount
9
unpleasantAdjective · 10 letters
SerialNumber
15
Word
unpleasant
PartOfSpeech
Adjective
LetterCount
10
inPreposition · 2 letters
SerialNumber
16
Word
in
PartOfSpeech
Preposition
LetterCount
2
theArticle · 3 letters
SerialNumber
17
Word
the
PartOfSpeech
Article
LetterCount
3
calendar.Noun · 8 letters
SerialNumber
18
Word
calendar.
PartOfSpeech
Noun
LetterCount
8
AfterPreposition · 5 letters
SerialNumber
19
Word
After
PartOfSpeech
Preposition
LetterCount
5
theArticle · 3 letters
SerialNumber
20
Word
the
PartOfSpeech
Article
LetterCount
3
deliciousAdjective · 9 letters
SerialNumber
21
Word
delicious
PartOfSpeech
Adjective
LetterCount
9
freedomNoun · 7 letters
SerialNumber
22
Word
freedom
PartOfSpeech
Noun
LetterCount
7
ofPreposition · 2 letters
SerialNumber
23
Word
of
PartOfSpeech
Preposition
LetterCount
2
SaturdayNoun · 8 letters
SerialNumber
24
Word
Saturday
PartOfSpeech
Noun
LetterCount
8
AndConjunction · 3 letters
SerialNumber
25
Word
And
PartOfSpeech
Conjunction
LetterCount
3
Sunday,Noun · 6 letters
SerialNumber
26
Word
Sunday,
PartOfSpeech
Noun
LetterCount
6
itPronoun · 2 letters
SerialNumber
27
Word
it
PartOfSpeech
Pronoun
LetterCount
2
wasVerb · 3 letters
SerialNumber
28
Word
was
PartOfSpeech
Verb
LetterCount
3
difficultAdjective · 9 letters
SerialNumber
29
Word
difficult
PartOfSpeech
Adjective
LetterCount
9
toPreposition · 2 letters
SerialNumber
30
Word
to
PartOfSpeech
Preposition
LetterCount
2
getVerb · 3 letters
SerialNumber
31
Word
get
PartOfSpeech
Verb
LetterCount
3
intoPreposition · 4 letters
SerialNumber
32
Word
into
PartOfSpeech
Preposition
LetterCount
4
theArticle · 3 letters
SerialNumber
33
Word
the
PartOfSpeech
Article
LetterCount
3
MondayNoun · 6 letters
SerialNumber
34
Word
Monday
PartOfSpeech
Noun
LetterCount
6
moodNoun · 4 letters
SerialNumber
35
Word
mood
PartOfSpeech
Noun
LetterCount
4
ofPreposition · 2 letters
SerialNumber
36
Word
of
PartOfSpeech
Preposition
LetterCount
2
workNoun · 4 letters
SerialNumber
37
Word
work
PartOfSpeech
Noun
LetterCount
4
andConjunction · 3 letters
SerialNumber
38
Word
and
PartOfSpeech
Conjunction
LetterCount
3
discipline.Noun · 10 letters
SerialNumber
39
Word
discipline.
PartOfSpeech
Noun
LetterCount
10
HePronoun · 2 letters
SerialNumber
40
Word
He
PartOfSpeech
Pronoun
LetterCount
2
shudderedVerb · 9 letters
SerialNumber
41
Word
shuddered
PartOfSpeech
Verb
LetterCount
9
atPreposition · 2 letters
SerialNumber
42
Word
at
PartOfSpeech
Preposition
LetterCount
2
theArticle · 3 letters
SerialNumber
43
Word
the
PartOfSpeech
Article
LetterCount
3
veryAdverb · 4 letters
SerialNumber
44
Word
very
PartOfSpeech
Adverb
LetterCount
4
thoughtNoun · 7 letters
SerialNumber
45
Word
thought
PartOfSpeech
Noun
LetterCount
7
ofPreposition · 2 letters
SerialNumber
46
Word
of
PartOfSpeech
Preposition
LetterCount
2
school:Noun · 6 letters
SerialNumber
47
Word
school:
PartOfSpeech
Noun
LetterCount
6
theArticle · 3 letters
SerialNumber
48
Word
the
PartOfSpeech
Article
LetterCount
3
dismalAdjective · 6 letters
SerialNumber
49
Word
dismal
PartOfSpeech
Adjective
LetterCount
6
yellowAdjective · 6 letters
SerialNumber
50
Word
yellow
PartOfSpeech
Adjective
LetterCount
6
building;Noun · 8 letters
SerialNumber
51
Word
building;
PartOfSpeech
Noun
LetterCount
8
theArticle · 3 letters
SerialNumber
52
Word
the
PartOfSpeech
Article
LetterCount
3
fire-eyedAdjective · 8 letters
SerialNumber
53
Word
fire-eyed
PartOfSpeech
Adjective
LetterCount
8
Vedanayagam,Noun · 11 letters
SerialNumber
54
Word
Vedanayagam,
PartOfSpeech
Noun
LetterCount
11
hisPronoun · 3 letters
SerialNumber
55
Word
his
PartOfSpeech
Pronoun
LetterCount
3
classNoun · 5 letters
SerialNumber
56
Word
class
PartOfSpeech
Noun
LetterCount
5
teacher,Noun · 7 letters
SerialNumber
57
Word
teacher,
PartOfSpeech
Noun
LetterCount
7
andConjunction · 3 letters
SerialNumber
58
Word
and
PartOfSpeech
Conjunction
LetterCount
3
headmasterNoun · 10 letters
SerialNumber
59
Word
headmaster
PartOfSpeech
Noun
LetterCount
10
withPreposition · 4 letters
SerialNumber
60
Word
with
PartOfSpeech
Preposition
LetterCount
4
hisPronoun · 3 letters
SerialNumber
61
Word
his
PartOfSpeech
Pronoun
LetterCount
3
thinAdjective · 4 letters
SerialNumber
62
Word
thin
PartOfSpeech
Adjective
LetterCount
4
longAdjective · 4 letters
SerialNumber
63
Word
long
PartOfSpeech
Adjective
LetterCount
4
cane...Noun · 4 letters
SerialNumber
64
Word
cane...
PartOfSpeech
Noun
LetterCount
4
Four word cards: It, was, Monday, morning.
Keep the supplied word cards in their original order. One occurrence is one card.
After two complete sentences, the supplied word table has He on card 11 and considered on card 12.
After two complete sentences, the supplied word table has He on card 11 and considered on card 12.

A position and a count are different

The supplied Word table has SerialNumber IDs 0–64. Card 12 is the thirteenth word occurrence. Each full stop is attached to its word, for example morning. and eyes. The first two sentences have 4 and 7 words, so the third begins at card 11.

Keep track of the current sentence

Set Sentence=1 before reading. For each word, first use the current sentence number to decide whether it is a candidate. After processing that word, if it ends with a full stop, increment Sentence. A word carrying the full stop still belongs to the sentence that just ended.

Sentence = 1
Found = False
Result = NONE
while (cards remain AND NOT Found AND Sentence <= 3) {
    Read next word X in SerialNumber order
    Move X to the visited pile
    if (Sentence == 3 AND X.PartOfSpeech == "Verb") {
        Found = True
        Result = X.SerialNumber
    }
    if (X.Word ends in a full stop) {
        Sentence = Sentence + 1
    }
}

Trace the actual answer

Card IDWordCategoryCurrent sentenceAction
10eyes.Noun2End sentence 2; next sentence becomes 3.
11HePronoun3Not a verb; continue.
12consideredVerb3Save 12, set Found=True and stop.

What if the target does not exist?

If there are fewer than three sentences, the pile can end without a match. If sentence 3 ends without a recorded verb, the Sentence<=3 guard prevents accepting a verb from sentence 4. Report “not found”. This is more precise than assuming every sentence must have a qualifying labeled verb.

The full-stop rule is the simplified rule for this dataset. Colons and semicolons inside its final sentence do not end the sentence. A general text-processing system would need explicit rules for abbreviations and other ending punctuation.

Try it yourself

Which word is the first recorded verb of sentence 3 in the supplied data?

Show explained answer

considered, SerialNumber 12. He at SerialNumber 11 is a pronoun.

Try it yourself

Why increment Sentence after handling a full-stop word?

Show explained answer

That word belongs to the sentence ending there. Incrementing first could assign it to the next sentence.

Try it yourself

Can the word cards be scanned in any order for this task?

Show explained answer

No. “First” and sentence boundaries require paragraph order.

Try it yourself

A comma appears on a word. Does this dataset’s rule end the sentence there?

Show explained answer

No. The simplified rule recognizes a full stop, not every punctuation mark.

Source: Lecture 2.1. Small teaching datasets and diagrams are prepared for these notes; lecture and tutorial totals are identified explicitly.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑