1 / 32

Algorithms & Flowcharts

PowerPoint Presentation on Algorithm and Flowchart

Kim146
Télécharger la présentation

Algorithms & Flowcharts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Understanding core concepts and applications Algorithms

  2. “… Whenever there is a problem, human being tries to find its solution…”

  3. There may be different solutions to a specific problem but.. To solve a particular problem, we need to follow certain steps in sequence. The problem may be so simple or may be very complex Problem Solving

  4. Examples include recipes in cooking, GPS navigation routes, and step-by-step procedures in software processes. Real-World Examples of Algorithms

  5. One problem (task) can be solved in different ways. (Solutions) Each solution must have a sequence of finite number of steps For each problem-solution set, there will be set of input and a set of output. Conclusion

  6. To do any task/job or to solve any problem we need to work on a set of input and after processing, we get output. Example: 5+9=14, here 2 and 3 are input and 5 is output. In making tea, water, sugar, tea leaves are input and after processing, tea is the output or final product. Input – Output

  7. "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". Definition of an Algorithm

  8. ALGORITHM -- HISTORY • 1. Muhammad al-Khwarizmi -  A Persian mathematician, astronomer, and geographer. • Wrote the foundational text "Kitab al-Jabr wa-l-Muqabala" (the origin of the word "Algebra"). • His name, Latinized as "Algoritmi," gave us the word "Algorithm." • He introduced systematic, step-by-step rules for solving linear and quadratic equations.

  9. ALGORITHM -- HISTORY • The very first of the many recognized algorithms have been attributed to the Babylonians around 1600 BC. The algorithms used for factorization and finding square roots.

  10. 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: • 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. • 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.

  11. Use of the Algorithms: • 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.

  12. What is the need for algorithms? • Algorithms are necessary for solving complex problems efficiently and effectively.  • They help to automate processes and make them more reliable, faster, and easier to perform. • Algorithms also enable computers to perform tasks that would be difficult or impossible for humans to do manually. • They are used in various fields such as mathematics, computer science, engineering, finance, and many others to optimize processes, analyze data, make predictions, and provide solutions to problems.

  13. Algorithms have different approaches to solve specific problems. On the basis of their approaches, algorithms can be categorized into different categories. What are the Characteristics of an Algorithm?

  14. For some instructions to be an algorithm, it must have the following characteristics: • 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.

  15. For some instructions to be an algorithm, it must have the following characteristics: • 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.

  16. For some instructions to be an algorithm, it must have the following characteristics: • 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.

  17. For some instructions to be an algorithm, it must have the following characteristics: • 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.

  18. 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. Properties of Algorithm:

  19. 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. Advantages of Algorithms

  20. 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). Disadvantages of Algorithms

  21. To write an algorithm, the following things are needed as a pre-requisite:  The problem that is to be solved by this algorithm i.e. clear problem definition. The constraints of the problem must be considered while solving the problem. The input to be taken to solve the problem. The output is to be expected when the problem is solved. The solution to this problem is within the given constraints. How to Design an Algorithm?

  22. Let us introduce an important concept of algorithm (as well as a computer program), it is called a variable. In an algorithm, we need to store several values such as input, some intermediate results and output. We can store values in variables. Variables are something that can store values, one at a time. Say, x=9. Here, x is the variable whose value is currently 9, or we can say that 9 is stored in variable ‘x’. Introduction to variable

  23. Type of variable: All variable must be declared before us. A variable must be declared with its name along with its type. Type of a variable means, type of value we need to store on that variable Suppose, We need to store values such as 1,2, 101 etc., then type of variable will be integer. I we need to store 2.5, or 10.20029 etc. we need variables of type decimal or float or double. Introduction to variable

  24. A variable can store only one value at a time. For multiple initialization, Last value will be the value of the variable. Example: x=9 …. x=2 So now, value of x is 2 Simultaneous initialization is not possible. Example: x=1,2 not possible Introduction to variable

  25. Consider the following segment: A=1 B=2 C=A+B Here, value of A and B variable is 1 and 2 respectively. At last line, value of AandBare getting added and stored on another variable C. So , value of C is 3. We can say that C storing the sum of A and B Introduction to variable

  26. Type of variable: All variable must be declared before us. A variable must be declared with its name along with its type. Type of a variable means, type of value we need to store on that variable Suppose, We need to store values such as 1,2, 101 etc., then type of variable will be integer. I we need to store 2.5, or 10.20029 etc. we need variables of type decimal or float or double. Introduction to variable

  27. STEP-1: START STEP-2: Declare variable a, b, s of type integer STEP-3: Input two integer value from user and store it in variable a and b STEP-4: Do addition of a and b and store the summation in variable s s = a + b STEP-5: Display value of variable s STEP-6: STOP Example-1 Algorithm – Addition of two numbers and display

  28. STEP—A step is a logical unit of an algorithm. It can be one line or it can be multiple lines. All steps must have distinct STEP number. It indicates the finiteness of the algorithms. START/STOP—Common convention to start and terminate an algorithm. In place of START-STOP, we can use BEGIN-END combination. DECLARATION-All variables must be declared with its type before use. In this example variable a, b, s has been declared in STEP-2. Algorithm – Explanation

  29. STEP-1: START STEP-2: Declare variable area, base, height of type decimal. STEP-3: Initialize base and height from user. STEP-4: Calculate area of triangle using formula and store the result in variable area. area=0.5 * base * height STEP-5: Display value of area. STEP-6: STOP Example-2 Algorithm – Calculate area of triangle

  30. Here variables are declared as decimal as there can be fractional part in area, base and height. Remember, In a decimal variable we can keep integer value. But opposite is not true Variable name need not to be always one alphabet. It can be anything. Here, we have used the formula: half x base x height to calculate area. In computer ‘*’ has been used as multiplication operator. Algorithm – Explanation

  31. Natural Language: Here we express the Algorithm in the natural English language. It is too hard to understand the algorithm from it. Flowchart: Here we express the Algorithm by making a graphical/pictorial representation of it. It is easier to understand than Natural Language. Pseudo Code: Here we express the Algorithm in the form of annotations and informative text written in plain English which is very much similar to the real code but as it has no syntax like any of the programming languages, it can’t be compiled or interpreted by the computer. It is the best way to express an algorithm because it can be understood by even a layman with some school-level knowledge. How to express an Algorithm?

  32. THANKS!

More Related