Draw This - beginner
Draw a flowchart to search for a number 7 in the list: [3, 5, 7, 9, 11]. Show each step of checking elements until the number is found or the list ends.
7 minutes
Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Draw a flowchart to search for a number 7 in the list: [3, 5, 7, 9, 11]. Show each step of checking elements until the number is found or the list ends.
+-------+
| Start |
+-------+
|
v
+-----------------+
| Set index = 0 |
+-----------------+
|
v
+-----------------------------+
| Is index < length of list? |----No----->+------------+
+-----------------------------+ | Not Found |
|Yes +------------+
v
+-----------------------------+
| Is list[index] == 7? |----Yes----->+---------+
+-----------------------------+ | Found |
|No +---------+
v
+-----------------+
| index = index+1 |
+-----------------+
|
v
(loop back to check index < length)
This flowchart starts by setting an index to 0, which points to the first element in the list.
It checks if the index is still within the list length. If not, it means the number 7 was not found, so it ends with 'Not Found'.
If the index is valid, it compares the current element with 7. If they match, it ends with 'Found'.
If not, it increases the index by 1 and repeats the check until it finds 7 or reaches the end.