KEMBAR78
Unit 7 - Revision Notes (CS) | PDF | Algorithms | Input/Output
0% found this document useful (0 votes)
16 views13 pages

Unit 7 - Revision Notes (CS)

The document outlines the program development life cycle, focusing on analysis, design, coding, and testing phases. It discusses the importance of decomposition in problem-solving, the design of algorithms using structure diagrams, flowcharts, and pseudocode, as well as standard methods for searching and sorting data. Additionally, it covers validation techniques, error identification, and the significance of algorithmic thinking in creating effective solutions.

Uploaded by

praraemahesa
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)
16 views13 pages

Unit 7 - Revision Notes (CS)

The document outlines the program development life cycle, focusing on analysis, design, coding, and testing phases. It discusses the importance of decomposition in problem-solving, the design of algorithms using structure diagrams, flowcharts, and pseudocode, as well as standard methods for searching and sorting data. Additionally, it covers validation techniques, error identification, and the significance of algorithmic thinking in creating effective solutions.

Uploaded by

praraemahesa
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/ 13

unit algorithm Design a problem solving

new subtopic
new sub section
topic
Program Development Life cycle topic 1
newheadingwithin same
1 analysis requirements specification sub section

21 design

3 coding

a testing

analysis decomposition abstraction 1

abstraction keeps the key elements discards unnecessary detail info thats not required

decomposition breaks down a task into smaller parts canthen be further subdivided

Design 2

shows how the program should be developed

structure charts flowcharts pseudocode

coding Iterative testing 3 4

each module of the program is written

Iterative testing modular testsconducted code amended repeat until desired result

computer sub systems topic 2


subsystem smaller part of a computer system that works together with othersub systems

a ear winonlyfunction if sub systems work together engines breaks wheels etc

subsystems can be brokendown into smaller subsystems e.g engine sparkplugs sensors pistons

5 main sub systems in a computer


1 epo executes instructions

2 memory stores data andinstructions temporarily for cpucrams

3 storage storesdata and software permanently HDDSSD

a Inputdevices allows a user to enter information exeyboard mouse

s output devices displays information or creates a physical output emonitor printer

advantages of subsystems
helps troubleshoot problems in a computer system

ability to isolate a subsystem makes it easier to identify and fix issues eachsubsystem examined separately

developing software relies on the use of different sub systems to ensure they operate efficiently

gives developers and designers a clear picture of nowsubsystemshelpbuild complex systems

problem Decomposition

what is decomposition

decomposition process of breaking down a large problem into a set of smaller problem

Benefits of decomposition

smaller problems are easier to solve

each smaller problem can be solved independently of the others


smaller problems can be tested independently

smaller problems can be combined to provide a solution to the full problem

example modern computer games Decomposed into

Levels can be designed created I tested independently of other levels


characters mechanics of characters can be designed and created by a separate team

Landscape are team can work on the visual aspects of the game without understand

once all smaller problems are completed joining together forms a complex game
Inputs processes outputs and storage

decomposing a problem requires developers to think about four components

inputs data entered into the system

processes subroutines and algorithms that turn inputs stored data into outputs

outputs data that is produced by the system e.g info on a screen or printed info

storage data stored on a physical device hard drive or in memory whilst program's running

Algorithms topic 3

Designing algorithms

algorithm precise set of rules or instructions to solve a specific problem or task

3 main ways to design an algorithm structure diagrams flowchart pseudocode

structure Diagrams

each problem is divided into sub problems and each sub problem divided into further problems

At each level the problem is broken down into more and more detailed tasks

example of what a structure diagram

for a mobile application could be


Flow charts

flowcharts are a visual tool that uses shapes to represent different functions to describealgorith

flowcharts show the data that is input and output processes that take place any decisionsrepetit
lines are used to show the flow of control

example of a flowcharts

pseudocode

text based tool that uses shore english words statements to describe an algorithm

pseudocode is more structured in english but is very flexible

example casino would like a program that asks a user to enter an age
INPUT age

IF age 18 THEN

output welcome to the site

else

output sorry this site is for users 18 and over

ENDIE
explaining Algorithms

well designed algorithm should be able to be interpreted by a new user and easily explainable
algorithms can be written using flowcharts pseudocode or highlevel programming language

purpose of algorithm solve a problem algorithm instructions should make its purpose clear

standard methods of a solution topic 4

Linear search Bubble sort

searchingalgorithms are stepbystep instructions that a computer can follow to locate specific data

Linear search

starts with the first value in a dataset checks every value one at a time until all valueschec

linearsearch can be performed even if values are not in order

How to perform a linear search

1 check the first value


2 If it is value you're looking for STOP

3 ELSE move to next value and check

4 REPEATUNTIL you have checked all values and not found the value you're looking for

data s 2,8 1 9

target 11

found FALSE

FOR index 1 to 5 Do

If data index target THEN

found TRUE
output target found

BREAK

ENDIE

Next index

If found FALSE THEN

output target not found

ENDIE

Bubble sort

sorting algorithms are precise stepby step instructions used to efficiently sort data in datasets

re
Bubble sort to
simple sorting algorithm that starts at beginning of dataset checks values in pairs swaps th

one full run of comparisonsfrom beginning to end is called a pass may require multiple passes
algorithm is finished when there are no more swaps to make

How to perform a bubble sort

1 compare the first two values in the dataset


2 if they are in the wrong order swap them
3 compare the next two values

4 Repeat steps 2 3 until you reach end of dataset pass 1

5 if you have made any swaps repeat from the start pass 2,3 4
6 else you have not made any swaps stop list is in

nums 66,7 69 50 42 80 71 321 67 8 39


numlength 11

swaps TRUE
while swaps Do

swaps false
FOR y 1 to numlength I Do

If numseys numscytis THEN

temp numscys

numseys nums y is

numscytes temp

swaps TRUE

ENDIE

Next y

numlength numlength 1

ENDWHILE

OUTPUT nums

other standard methods of a solution

Totalling counting

totalling is keeping a running total of all values entered into the algorithm

example totalling a receipt for purchases made at a shop

total
FOR count 1 to receipt
length

value
INPUT Item

total total Itemvalue

nextcount

output total
counting

when a count is incremented decremented


by a fixed value each time it iterates

keeps track of the number of times an action has been performed

count

REPEAT

output pass number count

count count 1

until count 50

maximum minimum average

total o

scores 2s 11 84 91 27

Highest max scores

Lowest min scores

FOR count o to Lenothe


scores 1

Total total counts


scores

next count

average total LENGTH scores

output Highest score is Highest

output cowest score is Lowest

output the average score is average


validation verification topic 5
automated process where a computer enecks if a user input is sensible meets requirements

6 categories rangecheck Lengen check typeeneck presence check format check check Digit

range check checks if value of


a number is between an upper and lower value
forexample eneckingpercentagescores are between o and100

output please enter the student's mark

REPEAT

INPUT studentmark

Jane
qq.gg q gggggang
yease reenter the mark
ENDIE

until studentmark 3 0 And studentmark 100

length check checks if data contains an exact number of characters


password must have 8 characters passwords with or a characters would be rejented
example

output please enter your password of eight characters


REPEAT

INPUT password

If Length password as 8 then Jeanne eerie

output the password should be exactly 8 characters


please re enter
ENDIE

until LENGTH password 8


Type eneck enecks if data entered is of a given data type
number of brotherssisters would be an integer example

output How many brothers do you have

REPEAT

INPUT numberofBrothers

p mg gqrs.mmen a

ENDIE

UNTIL numberofBrothers DivenumberofBrothers 1

beenentered
retina.chiessfor iingtoma ee atipiehas

output please enteryouremail address

REPEAT

INPUT email
address

mannan men

output required

ENDIE

address as
UNTIL email

format check enecks if characters entered conform to a predefinedpattern


chapter a cub number must be cubaaaa format example

eneck digit final digit included in a code calculated fromall otherdigits


used for barcodes vin's ISBN productcodes

used to identifyerrors in data entry caused by mistyping or mis scanning a barcode

incorrect digitentered
e.g 5327 instead of5307
transposition errors where two numbers havechangedorder 5037 insteadof 5307

omitted orextra digits 537or 51307instead of 5307

phoneticerrors is instead of 30

Double entry checking entering the data twice in separate boxes then comparing them

visual checks involve user visually checking the data on the screen

test data

suitabletest data is specifically chosen to test the functionality of a program or design

multiple categories normal abnormal extreme boundary

results would be compared to the expected results to check if algorithm works as intended

normal data data that should be accepted in the program


user enteringage as to into agefield of program

ae a ii i i ran

extreme data maximum and minimum values of normal data that's accepted by the system
user entering age as is or 12 into the age field of the program

Boundary data accept values on eitherside of the maximum and minimum values are tested

largest and smallest value is tested as well as the largest and smallest unacceptable
acceptable
e
userenteringage as a or ia into age field of program

trace tables

used to test algorithms and programs for logic errors that appear when an algorithm is executed

can be used with flowcharts pseudocode or program code

can be used to discover the purpose of an algorithm record the state of the algorithm
Example

Below is a flowchart to determine highest number of ten user entered numbers

algorithm prompts user to enter the first number automatically becomes highest number

user is then prompted to enter nine more numbers if new no is higher it's replaced

once all ten numbers are entered algorithm outputs highest number

example test data 4,3 7 1 8 3 6 a 12 10

Identifying errors topic 6

3 main categories of errors syntax errors logicerrors runtime errors

syntax error

error that breaks the grammatical rules of a programming language and stops it from running

examples typos spelling errors misplaced brackets misplaced semicolons incorrectuseofoperal

Logic error

incorrect code is used that causes program to run produces incorrect output result

logicerrors can be difficult to identify trace tables are used

examples logical operator confusion looping one extra time incorrect indexing infinite loops
Runtime errors

runtime errors cause a program to crash

examples dividing a number by o index out of the range of an array etc

writing amending algorithms

algorithmic thinking

process of creating stepbystep instructions in order to produce a solution to a problem

requires the use of abstraction and decomposition

algorithmic thinking can lead to


solutions being automated

example following a recipe precisely leads to desired outcome

You might also like