Before writing code, a good programmer plans. Decomposition breaks a problem into smaller parts, and abstraction keeps only the details that matter. The plan becomes an algorithm, written as a flowchart or in pseudocode. Standard methods solve common tasks: linear search, bubble sort, totalling, counting and finding the largest or smallest value. Validation checks that input is sensible, and verification checks that it was entered correctly. A trace table follows an algorithm step by step to find its output or its errors. Testing with normal, abnormal, extreme and boundary data shows whether it works.
Lessons, worked problems and more questions on Algorithms and Problem-Solving →WHILE Found = FALSE AND Index <= 20 DO, and the array has items, with Index starting at . The wanted item is not in it. How many comparisons are made?Index becomes and the loop stops.
forgets the last item. counts the test that ends the loop, which compares no item. would mean the loop never ran.Log in to join the discussion.
Loading…