Bird
Raised Fist0
Intro to Computingfundamentals~10 mins

Search engines and how they find information in Intro to Computing - Interactive Code Practice

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a simple search by checking if the keyword is in the document.

Intro to Computing
if '[1]' in document:
    print('Keyword found!')
Drag options to blanks, or click blank then click option'
Akeyword
Bdocument
Csearch
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'document' instead of 'keyword' inside the if condition.
2fill in blank
medium

Complete the code to add a document to the search index dictionary.

Intro to Computing
search_index['[1]'] = document_text
Drag options to blanks, or click blank then click option'
Adocument_text
Bkeyword
Cindex
Ddoc_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'keyword' as the key instead of a document ID.
3fill in blank
hard

Fix the error in the code that searches for documents containing the keyword.

Intro to Computing
for doc_id, text in search_index.items():
    if '[1]' in text:
        print(f'Document {doc_id} matches')
Drag options to blanks, or click blank then click option'
Asearch_index
Bdoc_id
Ckeyword
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Checking if 'doc_id' is in text, which is incorrect.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length if the length is greater than 3.

Intro to Computing
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(word) > 3
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'word > 3' which compares a string to a number.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their frequency if frequency is more than 1.

Intro to Computing
{ [1]: [2] for [3] in word_freq.items() if [2] > 1 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bfreq
Cword
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'count' instead of 'freq' for frequency variable.

Practice

(1/5)
1. What is the main role of a search engine crawler?
easy
A. To display search results to users
B. To organize information into categories
C. To visit web pages and collect information
D. To delete outdated web pages from the internet

Solution

  1. Step 1: Understand the crawler's function

    A crawler is a program that visits many web pages to gather data.
  2. Step 2: Differentiate from other parts

    Unlike indexers or searchers, crawlers focus on collecting information, not organizing or displaying it.
  3. Final Answer:

    To visit web pages and collect information -> Option C
  4. Quick Check:

    Crawler = Collects data [OK]
Hint: Crawlers collect data by visiting pages [OK]
Common Mistakes:
  • Confusing crawlers with indexers
  • Thinking crawlers display results
  • Assuming crawlers delete pages
2. Which of the following is the correct order of steps a search engine uses to find information?
easy
A. Indexing -> Crawling -> Searching
B. Searching -> Crawling -> Indexing
C. Searching -> Indexing -> Crawling
D. Crawling -> Indexing -> Searching

Solution

  1. Step 1: Recall the search engine process

    First, the crawler visits pages (Crawling), then the data is organized (Indexing), and finally results are shown (Searching).
  2. Step 2: Match the correct sequence

    Only Crawling -> Indexing -> Searching lists the steps in the correct order.
  3. Final Answer:

    Crawling -> Indexing -> Searching -> Option D
  4. Quick Check:

    Process order = Crawling, Indexing, Searching [OK]
Hint: Remember: Crawl first, then index, then search [OK]
Common Mistakes:
  • Mixing up the order of steps
  • Thinking searching happens before indexing
  • Assuming indexing happens before crawling
3. Consider this simplified flowchart of a search engine process:



What happens immediately after the search query is received?
medium
A. The search engine shows the results
B. The search engine indexes the data
C. The search engine crawls new web pages
D. The search engine deletes old data

Solution

  1. Step 1: Analyze the flowchart sequence

    The flowchart shows the steps: Crawl -> Index -> Search Query -> Show Results.
  2. Step 2: Identify the step after receiving the search query

    After the search query, the next step is to show the results to the user.
  3. Final Answer:

    The search engine shows the results -> Option A
  4. Quick Check:

    After query = Show results [OK]
Hint: After query input, results are displayed [OK]
Common Mistakes:
  • Thinking crawling happens after query
  • Confusing indexing with showing results
  • Assuming data deletion occurs here
4. A student wrote this description of how search engines work:

"Search engines first show results, then crawl web pages, and finally index the data."

What is wrong with this description?
medium
A. Crawling happens after indexing
B. The order of steps is incorrect
C. Search engines do not index data
D. Search engines delete data before crawling

Solution

  1. Step 1: Review the correct order of search engine steps

    The correct order is crawling first, then indexing, and finally showing results.
  2. Step 2: Compare with the student's description

    The student says results are shown first, which is incorrect.
  3. Final Answer:

    The order of steps is incorrect -> Option B
  4. Quick Check:

    Correct order ≠ student's order [OK]
Hint: Remember: Crawl -> Index -> Show results [OK]
Common Mistakes:
  • Believing results show before crawling
  • Thinking indexing is optional
  • Assuming data deletion is part of the main steps
5. Imagine a search engine that only crawls web pages but never indexes the data. What problem would users face when searching?
hard
A. Users would get no search results or irrelevant ones
B. Search results would be slow but accurate
C. The search engine would delete all web pages
D. Users would see only images, not text

Solution

  1. Step 1: Understand the role of indexing

    Indexing organizes and stores data so the search engine can quickly find relevant results.
  2. Step 2: Consider the effect of missing indexing

    Without indexing, the search engine cannot match queries to relevant pages, so users get no or irrelevant results.
  3. Final Answer:

    Users would get no search results or irrelevant ones -> Option A
  4. Quick Check:

    No indexing = no relevant results [OK]
Hint: No indexing means no useful search results [OK]
Common Mistakes:
  • Thinking results would still be accurate
  • Assuming crawling deletes pages
  • Believing search shows only images