0% found this document useful (0 votes)
10 views5 pages

B Algorithmic Design Document

The document is an algorithm design template for CS 161A/B, guiding students through the planning phase before coding their programs. It includes sections for zyBooks screenshots, program descriptions, sample runs, and algorithmic design, emphasizing the importance of pre-coding planning. Students are instructed to complete the document and submit it as a PDF after filling in the required information.

Uploaded by

huy427558
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

B Algorithmic Design Document

The document is an algorithm design template for CS 161A/B, guiding students through the planning phase before coding their programs. It includes sections for zyBooks screenshots, program descriptions, sample runs, and algorithmic design, emphasizing the importance of pre-coding planning. Students are instructed to complete the document and submit it as a PDF after filling in the required information.

Uploaded by

huy427558
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CS 161A/B: Programming and Problem Solving I

Algorithm Design Document


Make a copy before you begin (File -> Make a copy). Add the Assignment # above and complete the
sections below BEFORE you begin to code. The sections will expand as you type. When you are finished,
download this document as a PDF (File -> Download -> PDF) and submit to D2L.

This document contains an interactive checklist. To mark an item as complete, click on the box (the entire
list will be highlighted), then right click (the clicked box will only be highlighted), and choose the
checkmark.

Planning your program before you start coding is part of the development process. In this
document you will:

❏​ Paste a screenshot of your zyBooks Challenge and Participation %


❏​ Paste a screenshot of your assigned zyLabs completion
❏​ Write a detailed description of your program, at least two complete sentences
❏​ If applicable, design a sample run with test input and output
❏​ Identify the program inputs and their data types
❏​ Identify the program outputs and their data types
❏​ Identify any calculations or formulas needed
❏​ Write the algorithmic steps as pseudocode or a flowchart
❏​ Tools for flowchart - Draw.io - Diagrams.net

1. zyBooks
Add your zyBooks screenshots for the % and assigned zyLabs completions below. Required
percentages: all assigned zyLabs, Challenge Activity with at least 70%, and Participation
Activity with at least 80%.

Challenge and Participation % screenshot:

Assigned zyLabs completion screenshot:

1
2. Program Description
In the box below, describe the purpose of the program. You must include a detailed description
with at least two complete sentences.

Program description:

3. Sample Run
If you are designing your own program, you will start with a sample run. Imagine a user is
running your program - what will they see? What inputs do you expect, and what will be the
outputs from the given inputs? Choose test data you will use to test your program. Calculate
and show the expected outputs. Use the sample run to test your program.

Sample run:

4. Algorithmic Design
Before you begin coding, you must first plan out the logic and think about what data you will
use to test your program for correctness. All programmers plan before coding - this saves a lot
of time and frustration! Use the steps below to identify the inputs and outputs, calculations, and
steps needed to solve the problem.

Use the pseudocode syntax shown in the document, supplemented with English phrases if
necessary. Do not include any implementation details (e.g. source code file names, class
or struct definitions, or language syntax). Do not include any C++ specific syntax or data
types.

Algorithmic design:

a.​ Identify and list all of the user input and their data types. Include a variable name, data
type, and description. Data types include string, integer, floating point, (single) character,
and boolean. Data structures should be referenced by name, e.g. “array of integer” or
“array of string (for CS161B and up).

2
b.​ Identify and list all of the user output and their data types. Include a variable name, data
type, and description. Data types include string, integer, floating point, (single) character,
and boolean. Data structures should be referenced by name, e.g. “array of integer” or
“array of string” (for CS161B and up).

c.​ What calculations do you need to do to transform inputs into outputs? List all formulas
needed, if applicable. If there are no calculations needed, state there are no calculations
for this algorithm. Formulae should reference the variable names from step a and step b
as applicable.

d.​ Design the logic of your program using pseudocode or flowcharts. Here is where you
would use conditionals, loops or functions (if applicable) and list the steps in transforming
inputs into outputs. Walk through your logic steps with the test data from the assignment
document or the sample run above.​
Use the syntax shown at the bottom of this document and plain English phrases.
Do not include any implementation details (e.g. file names) or C++ specific syntax.

5. Pseudocode Syntax
Think about each step in your algorithm as an action and use the verbs below:

To do this: Use this verb: Example:

Create a variable DECLARE DECLARE integer num_dogs

Print to the console DISPLAY DISPLAY “Hello!”


window

Read input from the user INPUT INPUT num_dogs


into a variable

3
Update the contents of a SET SET num_dogs = num_dogs + 1
variable

Conditionals

Use a single alternative IF condition THEN IF num_dogs > 10 THEN


conditional statement DISPLAY “That is a lot of
statement dogs!”
END IF END IF

Use a dual alternative IF condition THEN IF num_dogs > 10 THEN


conditional statement DISPLAY “You have more than
statement 10 dogs!”
ELSE ELSE
statement DISPLAY “You have ten or
statement fewer dogs!”
END IF END IF

Use a switch/case SELECT variable or SELECT num_dogs


statement expression CASE 0: DISPLAY “No dogs!”
CASE value_1: CASE 1: DISPLAY “One dog..”
statement CASE 2: DISPLAY “Two dogs..”
statement CASE 3: DISPLAY “Three
CASE value_2: dogs..”
statement DEFAULT: DISPLAY “Lots of
statement dogs!”
CASE value_2: END SELECT
statement
statement
DEFAULT:
statement
statement
END SELECT

Loops

Loop while a condition is WHILE condition SET num_dogs = 1


true - the loop body will statement WHILE num_dogs < 10
execute 0 or more times. statement DISPLAY num_dogs, “ dogs!”
END WHILE SET num_dogs = num_dogs + 1
END WHILE

Loop while a condition is DO SET num_dogs = 1


true - the loop body will statement DO
execute 1 or more times. statement DISPLAY num_dogs, “ dogs!”
WHILE condition SET num_dogs = num_dogs + 1
WHILE num_dogs < 10

Loop a specific number FOR counter = start TO end FOR count = 1 TO 10


of times. statement DISPLAY num_dogs, “ dogs!”
statement END FOR
END FOR

Functions

4
Create a function FUNCTION return_type name FUNCTION Integer add(Integer
(parameters) num1, Integer num2)
statement DECLARE Integer sum
statement SET sum = num1 + num2
END FUNCTION
RETURN sum
END FUNCTION

Call a function CALL function_name CALL add(2, 3)

Return data from a RETURN value RETURN 2 + 3


function

You might also like