Computer Science - Introduction to Algorithms
**I. What is an Algorithm?** An algorithm is a step-by-step procedure or formula for
solving a problem or accomplishing a task. It's a set of instructions that a computer can
follow. Think of it like a recipe for solving a specific problem. **II. Characteristics
of a Good Algorithm:** * **Finiteness:** It must terminate after a finite number of
steps. * **Definiteness:** Each step must be precisely defined. * **Input:** It must have
zero or more inputs. * **Output:** It must have one or more outputs. * **Effectiveness:**
Each step must be feasible. **III. Examples of Algorithms:** * **Searching:** Finding a
specific item in a list (linear search, binary search). * **Sorting:** Arranging items in
a specific order (bubble sort, merge sort). * **Graph traversal:** Visiting all nodes in a
graph (breadth-first search, depth-first search). **IV. Representing Algorithms:**
Algorithms can be represented in several ways: * **Natural language:** Describing the
steps in plain English. * **Flowcharts:** Using diagrams to show the flow of
instructions. * **Pseudocode:** A combination of natural language and programming
constructs. **V. Example: Linear Search Algorithm (in pseudocode):** ``` function
linearSearch(list, item) for each element in list if element equals item
return true // Item found return false // Item not found ``` **VI. Practice Problems:**
1. Describe an algorithm for finding the largest number in a list. 2. Draw a flowchart
for an algorithm that adds two numbers. 3. Write pseudocode for an algorithm that checks
if a number is even or odd. Remember to consult your textbook and teacher for further
clarification and additional information. These notes are meant to be a helpful starting
point for your understanding.