We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33
Algorithm
After going through this module, you
are expected to: 1. Describe algorithms through varied examples. 2. Develop a set of algorithms to solve a problem. 3. Recognize that alternative Before we are going to start our lesson, let us test your knowledge through this pre- assessment.
Directions: Encircle the letter with the
correct answer. 1. What is an algorithm? a) A type of computer programming language b) A set of instructions for solving a problem c) A diagram that shows the steps in a process d) A mathematical equation 2. What is a Divide and Conquer Algorithm? a) break a complex problem into a collection of simpler subproblems b) divide the problem into smaller subproblems of the same type c) solve the lowest and simplest version of a problem d) try all possible solutions until a satisfactory solution is found. 3. Which of the following is NOT a characteristic of a good algorithm? a) Clear and concise instructions b) Logical order of steps c) Use of complex programming language d) Ability to be executed by a computer or human 4. What is the purpose of using algorithms? a) To create a working computer program b) To test a program for errors c) To solve a problem or accomplish a task d) To document a program for future reference 5. Which of the following is an example of an algorithm used in everyday life? a) Making a cup of coffee b) Playing a video game c) Searching for information online d) All of the above 6. What is an algorithm? a) A computer program b) A mathematical equation c) A set of instructions for solving a problem or accomplishing a task d) A type of computer hardware 7. Which of the following is NOT one of the major steps in the algorithm development process? a) Obtain a description of the problem b) Analyze the problem c) Develop a high-level algorithm d) Write the final computer program 8. What is the purpose of analyzing the problem in the algorithm development? a) To write the computer code b) To determine the starting and ending points for solving the problem c) To test the algorithm d) To publish the results 9. What is stepwise refinement in algorithm development? a) A process of gradually working from a high level to a detailed algorithm b) A method of solving mathematical equations c) A technique for writing computer code d) A way to debug programs 10. Which of the following is an example of an algorithm in everyday life? a) A computer b) A recipe c) A smartphone d) The Internet 11. What is the first step in the algorithm development process? a) Refine the algorithm b) Develop a high-level algorithm c) Obtain a description of the problem d) Review the algorithm
12. Which type of algorithm tries all possible solutions until a
satisfactory solution is found? a) Divide and conquer b) Brute force c) Greedy d) Recursive 13. What is the purpose of reviewing an algorithm? a) To make it longer b) To determine if it solves the original problem and look for improvements c) To translate it into a specific programming language d) To create a flowchart 14. Which of the following is NOT a type of algorithm mentioned in the document? a) Randomized algorithms b) Backtracking algorithms c) Sorting algorithms d) Dynamic programming algorithms 15. What does a high-level algorithm include? a) All the specific details of the implementation b) The major parts of a solution without minute details c) The complete computer codes d) The hardware specifications Create a Flowchart and write the steps you take when you log in to Facebook. FLOWCHART BEACH DAY Daniel, Kathryn and their dad went to the beach. First, Dad put sunscreen on Kathryn and Daniel. Next, they went for a walk and put shells into a bucket. Then, Daniel and Kathryn put on their floaties to go into the water. They had a lot of fun swimming together and splashing around. When they got out of the water Daniel, Kathryn and their dad built a sandcastle. Write the numbers 1,2, 3, 4, 5, and 6 to sequence the events below. Write your answer in the space provided.
__________ 1. Daniel, Kathryn, and their dad put shells into a
bucket. __________ 2. Daniel, Kathryn, and dad went to the beach. __________ 3. Daniel and Kathryn put on their floaties. __________ 4. Dad put sunscreen on Daniel and Kathryn. __________ 5. Daniel, Kathryn, and dad built a sandcastle. __________ 6. They went swimming. A computer algorithm is a computational procedure that takes in a set of finite input and transforms it into output by applying some math & logic. An algorithm in programming will have several steps as follows: 1. Problem definition 2. What needs to be done? 3. Data collection 4. What do we have to solve the problem? Algorithm means ” A set of finite rules or instructions to be followed in calculations or other problem-solving operations ” or “A procedure for solving a mathematical problem in a finite number of steps that frequently involves recursive operations”. Algorithm refers to a sequence of finite steps to solve a particular problem. Use of the Algorithms: Algorithms play a crucial role in various fields and have many applications. Some of the key areas where algorithms are used include: 1.Computer Science: Algorithms form the basis of computer programming and are used to solve problems ranging from simple sorting and searching to complex tasks such as artificial intelligence and machine learning. 2.Mathematics: Algorithms are used to solve mathematical problems, such as finding the optimal solution to a system of linear equations or finding the shortest path in a graph. 3.Operations Research: Algorithms are used to optimize and make decisions in fields such as transportation, logistics, and resource allocation. 4. Artificial Intelligence: Algorithms are the foundation of artificial intelligence and machine learning, and are used to develop intelligent systems that can perform tasks such as image recognition, natural language processing, and decision-making. 5. Data Science: Algorithms are used to analyze, process, and extract insights from large amounts of data in fields such as marketing, finance, and healthcare. What are the Characteristics of an Algorithm? • Clear and Unambiguous: The algorithm should be unambiguous. Each of its steps should be clear in all aspects and must lead to only one meaning. • Well-Defined Inputs: If an algorithm says to take inputs, it should be well- defined inputs. It may or may not take input. • Well-Defined Outputs: The algorithm must clearly define what output will be yielded and it should be well-defined as well. It should produce at least 1 output. • Finite-ness: The algorithm must be finite, i.e. it should terminate after a finite time. • Feasible: The algorithm must be simple, generic, and practical, such that it can be executed with the available resources. It must not contain some future technology or anything. • Language Independent: The Algorithm designed must be language-independent, i.e. it must be just plain instructions that can be implemented in any language, and yet the output will be the same, as expected. • Input: An algorithm has zero or more inputs. Each that contains a fundamental operator must accept zero or more inputs. • Output: An algorithm produces at least one output. Every instruction that contains a fundamental operator must accept zero or more inputs. • Definiteness: All instructions in an algorithm must be unambiguous, precise, and easy to interpret. By referring to any of the instructions in an algorithm one can clearly understand what is to be done. Every fundamental operator in instruction must be defined without any ambiguity. • Finiteness: An algorithm must terminate after a finite number of steps in all test cases. Every instruction which contains a fundamental operator must be terminated within a finite amount of time. Infinite loops or recursive functions without base conditions do not possess finiteness. • Effectiveness: An algorithm must be developed by using very basic, simple, and feasible operations so that one can trace it out by using just paper and pencil. Properties of Algorithm: • It should terminate after a finite time. • It should produce at least one output. • It should take zero or more input. • It should be deterministic means giving the same output for the same input case. • Every step in the algorithm must be effective i.e. every step should do some work. Advantages of Algorithms: • It is easy to understand. • An algorithm is a step-wise representation of a solution to a given problem. • In an Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program. Disadvantages of Algorithms: • Writing an algorithm takes a long time so it is time-consuming. • Understanding complex logic through algorithms can be very difficult. • Branching and Looping statements are difficult to show in Algorithms(imp).