Problem solving and program design Flashcards
What are the steps in problem solving
1) Define the problem
2) Propose suggestions and evaluate them to get the right solution
3) Determine the most efficient solution
4) Develop the algorithm
5) Test and validate the solution
a solution is …
a set of instructions that,
if followed in order
will produce the required information
What is an efficient solution?
An efficient solution is one that uses the least effort to get the most benefits.
In defining the solution, you must define … /what are the normal components of a computer solution
1) input - what info will be input
2) how info will be processed
3) output - what results will be output
4) info that needs to be stored (during the process, or to be kept for another time)
The divide-and-conquer approach is …
to repeatedly split a large problem into a number of smaller sub-problems
until a solution is identified
A computer program is …
a series of coded instructions for the computer
What is an algorithm?
An algorithm is
a sequence of instructions
that has a finite number of steps that if followed
produces a precise solution to the given problem
An algorithm must set out (3 responses)
An algorithm must set out
1) instructions - what actions to take
2) sequence - in what order
3) when to stop
2 types of algorithms
flowcharts
pseudocode
Pseudocode is …
a formal way of writing an algorithm
using English text, numbers and special characters
a language that resembles or models real programming language
a kind of structured English for describing algorithms
Flowchart is …
Diagrams that visually represent the series of instructions of algorithm
Difference between flowchart and pseudocode
Algorithms can be written using … (2 responses)
flowcharts and pseudocode
Algorithms, pseudocode and computer programs are written using __________ _____________ and ______________
Algorithms, pseudocode and computer programs are written using specific rules and statements
Computer programs are written in different ___________ __________
Computer programs are written in different computer languages
What are the steps in developing an algorithm
1) Define the problem
2) Analyze the solution
3) Develop an algorithm/method of
solving the problem
4) Write the pseudocode or flowchart corresponding to the algorithm
5) Test and validate the program
6) Document the program
What is a command?
A command is a word
that instructs a computer
what must be done
in order to accomplish a specific task
Commands are specific to
Commands are specific to a particular programming language
Every programming language has its own specific commands
Name 2 programming languages
Python
Pascal
Examples of commands - 4 responses
write
print
read
input
A construct is …. Give an example.
A construct is a group of instructions that work together with commands to accomplish a specific task.
An example is IF … THEN construct
Problem statement that what needs to be done
Problem statements that what is required for output
What are variables?
What can you store in a variable?
When write a program, you will write instructions to : (2 responses)
When write a program, you will write instructions to :
1) declare the variable - give it a name
2) Allow a value to be assigned to the variable
Declaring a variable means …
1) Giving the variable a name
2) saying what type of data it will store - data type
Rules in naming variables:
- short simple names
- meaningful name that remind of purpose of the variable
- must begin with a letter, not number
- no spaces
- example Age, FirstName, Cost
What are the 5 main data types in variables
1) Boolean or logic
2) Integer
3) Real number
4) Character
5) String
Boolean or logic data type can only store _______ or _________
Boolean or logic data type can only store
true or false, yes/no
Integer data type can only store __________
Integer data type can only store
whole numbers
no fractions or decimals