0
0
Intro to Computingfundamentals~10 mins

Searching algorithms (linear, binary) in Intro to Computing - Draw & Build Visually

Choose your learning style9 modes available
Draw This - beginner

Draw a flowchart for performing a linear search to find the number 7 in the list [3, 5, 7, 9, 11].

7 minutes
Hint 1
Hint 2
Hint 3
Hint 4
Grading Criteria
Start and End symbols present
Initialization of index variable shown
Decision symbol to check index < length
Decision symbol to compare current item with target
Correct loop back to index check after increment
Outputs correct result when found or not found
Solution
  +---------------------+
  |       Start         |
  +----------+----------+
             |
             v
  +---------------------+
  | Set index = 0       |
  +----------+----------+
             |
             v
  +---------------------+
  | Is index < length?  |----No----->+---------------------+
  +----------+----------+           |   Output: Not found  |
             |                      +----------+----------+
            Yes                                |
             |                                 v
             v                      +---------------------+
  +---------------------+          |        End          |
  | Is list[index] = 7? |--Yes---->+---------------------+
  | Output: Found at index |
  +----------+----------+
             |
            No
             |
             v
  +---------------------+
  | index = index + 1   |
  +----------+----------+
             |
             v
          (loop back to check index < length)

This flowchart shows how linear search works step-by-step:

  • Start with the first item (index 0).
  • Check if the current index is less than the list length to avoid going out of bounds.
  • If yes, compare the item at the current index with 7.
  • If it matches, output the position and end.
  • If not, increase the index by 1 and repeat the check.
  • If the index reaches the list length without finding 7, output 'Not found' and end.

This method checks each item one by one until it finds the target or finishes the list.

Variations - 2 Challenges
[intermediate] Draw a flowchart for performing a binary search to find the number 7 in the sorted list [1, 3, 5, 7, 9, 11].
[advanced] Draw a flowchart for performing a binary search to find the number 4 in the sorted list [2, 4, 6, 8, 10, 12, 14].