Top Down Design Brent M. Dingle Texas A&M University Chapter 4 – Section 1 (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)

Slides:



Advertisements
Similar presentations
AE1APS Algorithmic Problem Solving John Drake
Advertisements

A number of MATLAB statements that allow us to control the order in which statements are executed in a program. There are two broad categories of control.
The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP
Problem Solving and Algorithm Design
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
8 Algorithms Foundations of Computer Science ã Cengage Learning.
Jeroo Chapter 3 Problem Solving and Algorithms. Problem Solving and Algorithms  The story of Aunt Kay  A computer is a tool used to solve problems 
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
J. Michael Moore Software Design CSCE 110 Influenced by material developed by James Tam & Jennifer Welch.
Chapter 1 Program Design
CS 106 Introduction to Computer Science I 10 / 15 / 2007 Instructor: Michael Eckmann.
Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
Chapter 3 Planning Your Solution
New Mexico Computer Science For All Introduction to Algorithms Maureen Psaila-Dombrowski.
Simplifying Rational Expressions – Part I
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Towers of Hanoi. Introduction This problem is discussed in many maths texts, And in computer science an AI as an illustration of recursion and problem.
Recursion, Complexity, and Searching and Sorting By Andrew Zeng.
Problem Solving and Algorithms
Fall 2001(c)opyright Brent M. Dingle 2001 Arrays Brent M. Dingle Texas A&M University Chapter 9 – Sections 1 and 2 (and some from Mastering Turbo Pascal.
Advanced English Writing
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 3 Simple.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Simplifying Rational Expressions – Part II
Bishop Loveday CE Primary School Help your child with reading Year Five.
Chapter 4: Classes, Objects, and Parameters 4.1 World-Level methods.
Reading ACT Test. Format 40 questions/4 passages/35 minutes/ ½ minutes per passage 2-3 minutes to read each passage and 5-6 to answer questions.
Unaddition (Subtraction)
Algorithms CS139 – Aug 30, Problem Solving Your roommate, who is taking CS139, is in a panic. He is worried that he might lose his financial aid.
ALGORITHM CHAPTER 8. Chapter Outlines and Objectives  Define an algorithm and relate it to problem solving.  Define three construct and describe their.
Loops Brent M. Dingle Texas A&M University Chapter 7 – part D (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Software Engineering Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University.
1 CS161 Introduction to Computer Science Topic #9.
Loops Brent M. Dingle Texas A&M University Chapter 7 – part B (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
L061 Algorithms, Part 3 of 3 Topics Top down-design Structure charts Reading Sections , 3.3.
Writing a paragraph. What is a paragraph? A paragraph is a group of about sentences about one topic. Every sentence in a strong paragraph is about.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Fall 2001(c)opyright Brent M. Dingle 2001 Simple Sorting Brent M. Dingle Texas A&M University Chapter 10 – Section 1 (and some from Mastering Turbo Pascal.
1 UMBC CMSC 104, Section Fall 2002 Functions, Part 1 of 3 Topics Top-down Design The Function Concept Using Predefined Functions Programmer-Defined.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
Loops Brent M. Dingle Texas A&M University Chapter 7 – part C (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Loops Brent M. Dingle Texas A&M University Chapter 6 – Section 6.3 Multiway Branches (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Lists and Sorting Algorithms
Fall 2001(c)opyright Brent M. Dingle 2001 Multidimensional Arrays Brent M. Dingle Texas A&M University Chapter 10 – Section 2, part B (and some from Mastering.
Fall 2001(c)opyright Brent M. Dingle 2001 Abstract Data Types (ADTs) Brent M. Dingle Texas A&M University Chapter 8 – Sections 2 and 3 (and some from Mastering.
Algorithms IV Top-Down Design.
Brent M. Dingle Texas A&M University Chapter 6, Sections 1 and 2
CMSC201 Computer Science I for Majors Lecture 11 – Program Design
(c)opyright Brent M. Dingle 2001
Chapter 3 Simple Functions
Problem Solving Techniques
Written Description of Algorithms
Computational Thinking
Turbo Pascal Units (TPU)
Procedures Brent M. Dingle Texas A&M University
Big problem  small steps
Chapter 2 – part a Brent M. Dingle Texas A&M University
Computational Thinking
Algorithms, Part 3 of 3 Topics Top down-design Structure charts
(c)opyright Brent M. Dingle 2001
Brent M. Dingle Texas A&M University Chapter 5 – Section 2-3
2.2 Algorithms 26-Jun-19.
Complex Array Structures
Brent M. Dingle Texas A&M University Chapter 5 – Section 1
Algorithms, Part 3 of 3 Topics Top down-design Reading
CMSC201 Computer Science I for Majors Lecture 12 – Program Design
Presentation transcript:

Top Down Design Brent M. Dingle Texas A&M University Chapter 4 – Section 1 (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)

Definition Designing an algorithm to perform a task by breaking the task into smaller subtasks, and then breaking the subtasks into even smaller subtasks is called top-down design. Because you start at the biggest, most complex, task (the top) and break it into smaller subtasks thus moving down in complexity.

Synonyms Top-down design is also referred to as: the Divide and Conquer method the Stepwise Refinement method

Benefits Top-down design has proven itself to be an efficient and easily understood method of designing algorithms. The algorithms it produces are usually easy to understand and implement.

Outside computer science A builder starts with a blueprint and builds a foundation before building the walls. A musician begins with a theme or melody before adding trills. A writer starts with a general idea or an outline before writing the story. In sum, start “big” – get an overview of what must be done, then figure out the details.

Example Suppose you wanted to get dressed to go outside. What are the subtasks of getting dressed? Select what clothes you want to wear. Put on the selected clothes.

Example (cont 1) Now that we have the general idea of what subtasks are needed to get dressed, we need to see if we can break the subtasks down any further. What would the subtasks of “Selecting what clothes you want to wear” be?

Subtasks of Selecting Clothes Select undergarments (if any) Select pants (if any) Select shirt (if any) Select socks/hose (if any) Select shoes (if any) Select tie/neck adornment (if any) Select hat/head adornment (if any) Select jewelry (if any) Check that everything “goes together.” Reselect items that don’t go together Repeat until satisfied.

Subtasks of Put on the selected clothes Identify types of clothes selected (i.e. undergarments, outer garments, extras, jewelry, and so on). Put on undergarments, if any. Put on outer garments (shirts, pants, etc), if any. Put on extras (shoes, ties, etc), if any Put on jewelry, if any.

Subtasks Further Breakdown Could we break the selection tasks down any more? Most likely. Could we break the putting on tasks down any more? Most likely. In fact we could probably break them down so that we had a step by step explicit description. I’ll leave that for you to try, as the above should be enough to convey the idea of top-down design.

Challenge ( no grade ) Pretend you wanted to describe the task of going to a football game. Break it into subtasks. I’ll start: Go to football game Before game, Get tickets. On game day, go to the stadium. Enter stadium. Watch game. Can you break those subtasks down more? The question, “how ?” usually helps.

Challenge ( no grade ) Break the task: Mail a letter. into subtasks. The first subtask might be: Write a letter. The last subtask might be: Place envelope into mailbox.

Note Order and Similarity Notice that as you break the tasks down some sort of ORDER of tasks is often implied or necessary. Notice also some of the tasks may be very similar, so similar that if you just changed one or two words you would be writing the same description.

Similar tasks Notice that our list of “put on” subtasks is rather repetitive. What if we just made a subtask called PutOn(clothing item) Then we could say: For garment_type = [under garment] to [jewelry] do BEGIN For (all clothes selected) AND (not already put on) do Begin If (current clothing item is of garment_type) then PutOn( current clothing item) End END

Parameter Notice that in the above example our “put on” subtask would require a parameter of [clothing item].

Difficulty A difficulty in top-down design, when applying it to writing a program, is knowing exactly how far to break subtasks down. Experience helps in this matter. A general rule once suggested was that: No subtask when coded should take up more than a page. This is similar in Math to: No proof should take up more than a page (use lemmas to break it into smaller pieces) This is similar in English to: No paragraph should exceed one (typed) page. However, these are GENERAL rules and don’t always apply.

Pascal Pascal uses procedures and functions to perform subtasks. We will be seeing what those are shortly.

End Top Down Design