🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

23.08.2024.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Programming and Problem Solving Using C CAP1005 : Programming and Problem Solving using C Unit I : Introduction to Programming Name: Manka Sharma Date: 23rd August 2024 Learning Outcomes To learn about the Problem Definition and Analysis. To learn about t...

Programming and Problem Solving Using C CAP1005 : Programming and Problem Solving using C Unit I : Introduction to Programming Name: Manka Sharma Date: 23rd August 2024 Learning Outcomes To learn about the Problem Definition and Analysis. To learn about the steps in Problem Solving. To understand the concept and the need of Algorithm. To understand the concept of Flowchart To learn about Flowcharts To learn about the concept of Program Problem Definition and Analysis Problem Definition: problem definition refers to a clear statement that describes the objective of a program or application. It outlines the problem to be solved and the requirements of the solution. Problem statement: A concise description of the problem to be solved. This should be specific, measurable, and clear. Constraints: Any limitations or restrictions on the problem, such as time or memory constraints. Assumptions: Any assumptions made about the input or output data, or the problem itself Problem Definition and Analysis Expected behavior: A description of what the program should do when it is executed. Examples: Examples of input/output data to help clarify the problem Understanding the Problem Important points in Understanding the Problem Some of the important points that we should keep in mind while understanding the problem are as follows: Read the problem very carefully. Identify the functions that the solution (algorithm) should have. Identify the required output. Find a way to produce the required output. Draw a proper relationship between the input and output. Take all the necessary number of inputs. Avoid unnecessary inputs. Identify the correct number of the required input. Problem Analysis Problem Analysis Problem Analysis Problem Analysis Problem Analysis Problem Analysis Algorithm Algorithm The word 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 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. Operations Research: Algorithms are used to optimize and make decisions in fields such as transportation, logistics, and resource allocation. 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. Data Science: Algorithms are used to analyze, process, and extract insights from large amounts of data in fields such as marketing, finance, and healthcare. Algorithm Algorithm Algorithm - 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. 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. Algorithm 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. Algorithm Further Reading : https://www.javatpoint.com/algorithm -in-c-language Flowcharts A flowchart is a diagram that depicts a process, system or computer algorithm. They are widely used in multiple fields to document, study, plan, improve and communicate often complex processes in clear, easy-to- understand diagrams. Flowcharts, sometimes spelled as flow charts, use rectangles, ovals, diamonds and potentially numerous other shapes to define the type of step, along with connecting arrows to define flow and sequence. They can range from simple, hand-drawn charts to comprehensive computer-drawn diagrams depicting multiple steps and routes. Flowcharts are sometimes called by more specialized names such as Process Flowchart, Process Map, Functional Flowchart, Business Process Mapping, Business Process Modeling and Notation (BPMN), or Process Flow Diagram (PFD). They are related to other popular diagrams, such as Data Flow Diagrams (DFDs) and Unified Modeling Language (UML) Activity Diagrams. Flowcharts Symbols Flowcharts Symbols Flowcharts Symbols Flowcharts Flowcharts Flowcharts for computer programming/algorithms As a visual representation of data flow, flowcharts are useful in writing a program or algorithm and explaining it to others or collaborating with them on it. An algorithm flowchart is used to spell out the logic behind a program before ever starting to code the automated process. It can help to organize big-picture thinking and provide a guide when it comes time to code. More specifically, flowcharts can: Demonstrate the way code is organized. Visualize the execution of code within a program. Show the structure of a website or application. Understand how users navigate a website or program. Flowcharts Pseudocode Algorithm Vs Pseudocode Algorithm Vs Pseudocode Algorithm Pseudocode Program

Use Quizgecko on...
Browser
Browser