Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Structured Programming: Problem Solving, Algorithm Development, and Implementation, Lecture notes of Differential and Integral Calculus

Software EngineeringData StructuresProgramming Languages

An overview of structured programming, focusing on the problem-solving and implementation phases. It introduces the concept of algorithms, their properties, and the challenges in writing them. The document also covers the development and understanding of algorithms using flowcharts and a problem example.

What you will learn

  • What are the basic control structures in structured programming?
  • What is the role of flowcharts in understanding algorithms?
  • What are the two main phases of programming according to structured programming?
  • What are the steps involved in the problem-solving phase?
  • How do you develop an algorithm?

Typology: Lecture notes

2019/2020

Uploaded on 01/29/2020

doireann-a
doireann-a 🇨🇦

4 documents

1 / 17

Toggle sidebar

Related documents


Partial preview of the text

Download Structured Programming: Problem Solving, Algorithm Development, and Implementation and more Lecture notes Differential and Integral Calculus in PDF only on Docsity! Lecture 1 ENG 224 STRUCTURED PROGRAMMING PROBLEM SOLVING & PROGRAM DESIGN Two phases involved in the design of any program: (i) Problem Solving Phase (ii) Implementation Phase 1. In the problem-solving phase the following steps are carried out: Define the problem Outline the solution Develop the outline into an algorithm Test the algorithm for correctness 2. The implementation phase comprises the following steps: Code the algorithm using a specific programming language Run the program on the computer Document and maintain the program Algorithms and Humans Algorithms are not a natural way of stating a problem’s solution, because we do not normally state our plan of action. • We tend to execute as we think about the problem. Hence, there are inherent difficulties when writing an algorithm. • We normally tailor our plans of action to the particular problem at hand and not to a general problem (i.e. a nearsighted approach to problem solving) • We usually do not write out our plan, because we are usually unaware of the basic ideas we use to formulate the plan. We hardly think about it – we just do it. • Computer programmers need to adopt a scientific approach to problem solving, i.e. writing algorithms that are comprehensive and precise. • We need to be aware of the assumptions we make and of the initial conditions. • Be careful not to overlook a step in the procedure just because it seems obvious. • Remember, machines do not have judgment, intuition or common sense! Developing an Algorithm • Understand the problem (Do problem by hand. Note the steps) • Develop a plan (look for familiarity and patterns) • Carry out the plan (trace) • Review the plan (refinement) Understanding the Algorithm Possibly the simplest and easiest method to understand the steps in an algorithm, is by using the flowchart method. This algorithm is composed of block symbols to represent each step in the solution process as well as the directed paths of each step. The most common block symbols are: • Start/Stop • Decision • Process • Connector • Input/output • Flow Direction There are many other block symbols, used in flow charting, but for the purposes of this course, we will restrict our usage to the symbols described above. They are sufficient to illustrate the steps in developing solutions to the simple problems we will be dealing with. 2. Develop a plan: Make note of what you did in steps (i) through (iv), but how you did it. In doing so, you will begin to develop the algorithm. e.g. How do we count the numbers? • Starting at 0 i.e. set COUNTER to 0 • Look at 1st number, add 1 to COUNTER • Look at 2nd number, add 1 to COUNTER and so on , until you reach the end of the list How do we add numbers? • Let SUM be the sum of numbers in list. Set SUM to 0 • Look at 1st number, add number to SUM • Look at 2nd number, add number to SUM • and so on, until we reach end of list How do we compute the average? • Let AVE be the average then AVE = total sum of items/number of items i.e. SUM / COUNTER 3. Identify any patterns, repetitions and familiar tasks. Familiarity: Unknown number of items? i.e. n item Patterns : look at each number in the list Repetitions: Look at a number Add number to sum Add 1 to counter 5. Review the plan: • Can you derive the result differently? • Can you make the solution more general? • Can you use the solution or method for another problem? e.g. average temperature or average grades N.B: Before we write out the algorithm in its proper form, let’s introduce the concept of a VARIABLE. • A variable is a symbolic name assigned to a memory cell which stores a particular value. e.g. COUNTER, SUM, AVE 6. The Algorithmic Language During development of an algorithm, the language gradually progresses from English towards a programming language notation. An intermediate notation called pseudo- code is commonly used to express algorithms. Algorithmic Structure Every algorithm should have the following sections, in the stated order: • Header : Algorithm’s name or title. • Declaration : A brief description of algorithm and variables. i.e. a statement of the purpose. • Body : Sequence of steps • Terminator : End statement Note • Once the problem has been properly defined, making sure that no assumptions are made and every action required is stated in the Processing column, we can proceed to develop the algorithm. To do this, simply focus on the actions in the processing column, then write down the steps that specify how to perform each action and in what sequence
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved