Intro to CS Notes
Samikhaf
.
,① AlgorithmicThinking :
I toannizetr
-
asolve on
computational presi s
Naive Ideal : Natural
language instructions
PrepackagedSolutions lapps
:
Programming telling a computer what to do
Machine Language : easy for Computer , error-prone for human
Natural Language : easy for human
, error-prone for computer
High-level language : Some
difficulty for both
"Coding" Environment :
using set of pseudocode instructions to express a solution
algorithmically
An
algorithm Step-by-step process of
solving a problem
:
Ex : Problem : Find Sum of 2 numbers
=
Read X
Algorithm :
Ready
X+
Display y
Algorithm Development : As a 3 step process , with fedback
① Analyne : understand the problem you are
solving (inputs
& outputs , errors ,
exc .
② Solve : develop a step-by-step algorithm , use a
"language" to express i t
③ Evaluate :
Play a human computer to see how the algorithm wo r ks
Computational Thinking : Set of
problem-solving methods that involves expressing problems & their solutions
Stages of It : -
> Abstraction
-
problem formulation
>
-
Automation solution t h a t a machine
expressing a can execute
>
-
& evaluation
Analyses solution execution
I intended fo r h u m an
Pseudo Language : An informal high-level description of a computer program reading
helps express algorithm i n the
design cycle
-
High-level components in
Program Development :
in put
output
compute
Definitions terms used
pseudo language &
~
in
programming using a
variable) an entity that may change its value (e g .
temperature
>
constants a va l u e that does not
change (e .
g4)
expression( variables, constants and operators grouped together
to show value of
something (e g. . X& S +
y
, <
Boolean expression > an expression that evaluates to
TRUE/FALSE (e g. n> 3)
Statements a combination of expressions le g. Compute X As X+ 3)
Pseudo language Vocabulary :
110 Initialization Flow Control Repetition Nested Increment/Decrement
Computation If Then While - End while Nested -
For Add
Read
-
Set
Display If-Then-Else Do -
While Nested -
For-If Subtract
compute
Nested If-Then-Else Repeat -
until
For-End For
comparisons Arithmetic Operations Boolean operations Terminate Program
t NOT
L
HALT
-
AND
L =
* OR
7
/
> =
% - remainder
iS
!
Input : Read data from
memory [CRAMSJ or from an input device (keyboard/ disk)
Output : Display / write results to an output device (terminal/disk/printer)
↳
Read
new
( va r i a b l e temperature
:
: lay
Display variable/constant temperature
Initialize :
Using the SET statement in the pseudo language
>
-
SET <variable) TO < constant/variable
>
-
SET X TO 10
Compute
Using the COMPUTE statement in the pseudo language
>
-
COMPUTE <variable) A s expression >
>
-
COMPUTE X As
ytz
Flow Control One-way Branching :
-
IfThen .
One-way branching based on the condition
being TRUE
(number > 0
: If <Boolean-expression)
Display positive
Then
<
Statement/statements >
ENDIF
, Flow Control -
Two-way Branching :-
I f then-Else :
is based
Two-way branching on Condition being TRUE Or FALSE
Bortemperatureo
# If
day
The
stuisplay cod arents
ELSE
ants
Display , mid
ENDIF
Flow Control-Multi-way Branching :
Nested i f then-else multi
branching based &
:
way on condition being TRUE or FALSE more
temperature yo
: If <Brolean-condition) THEN
StaSPYcodasa
ELSE
If <Botmprature THE
< SESPLAYnota
sents
ELSE
DISPAYmidaySee n t
ENDIE
ENDIF
Iterations- WHILE Loop :
Initialization (optional (
-
Bookan Expression. Evaluate a Boolean expression
-
IF TRUE
· Execute a sequence of statements
-
Repeat
-
Set n to 3
Set sum to0
< initialization Statements >
:
n> 0
WHILE (Boolean
expression] -
COMPUTE Sum As S u m t n
statements if Boolean expression is true >
END SUBTRACT I FROMT
Iterations -
FOR
Loop :
-
Initialization. Evaluate an initiation statement
-
Boolean Expression. Evaluate a Boolean expression
-
EXTRUE . Execute a sequence of statements
Execute an increment statement
Repeat
-
For eachanyofthea we
Ex yofthece and
:
END FOR
Samikhaf
.
,① AlgorithmicThinking :
I toannizetr
-
asolve on
computational presi s
Naive Ideal : Natural
language instructions
PrepackagedSolutions lapps
:
Programming telling a computer what to do
Machine Language : easy for Computer , error-prone for human
Natural Language : easy for human
, error-prone for computer
High-level language : Some
difficulty for both
"Coding" Environment :
using set of pseudocode instructions to express a solution
algorithmically
An
algorithm Step-by-step process of
solving a problem
:
Ex : Problem : Find Sum of 2 numbers
=
Read X
Algorithm :
Ready
X+
Display y
Algorithm Development : As a 3 step process , with fedback
① Analyne : understand the problem you are
solving (inputs
& outputs , errors ,
exc .
② Solve : develop a step-by-step algorithm , use a
"language" to express i t
③ Evaluate :
Play a human computer to see how the algorithm wo r ks
Computational Thinking : Set of
problem-solving methods that involves expressing problems & their solutions
Stages of It : -
> Abstraction
-
problem formulation
>
-
Automation solution t h a t a machine
expressing a can execute
>
-
& evaluation
Analyses solution execution
I intended fo r h u m an
Pseudo Language : An informal high-level description of a computer program reading
helps express algorithm i n the
design cycle
-
High-level components in
Program Development :
in put
output
compute
Definitions terms used
pseudo language &
~
in
programming using a
variable) an entity that may change its value (e g .
temperature
>
constants a va l u e that does not
change (e .
g4)
expression( variables, constants and operators grouped together
to show value of
something (e g. . X& S +
y
, <
Boolean expression > an expression that evaluates to
TRUE/FALSE (e g. n> 3)
Statements a combination of expressions le g. Compute X As X+ 3)
Pseudo language Vocabulary :
110 Initialization Flow Control Repetition Nested Increment/Decrement
Computation If Then While - End while Nested -
For Add
Read
-
Set
Display If-Then-Else Do -
While Nested -
For-If Subtract
compute
Nested If-Then-Else Repeat -
until
For-End For
comparisons Arithmetic Operations Boolean operations Terminate Program
t NOT
L
HALT
-
AND
L =
* OR
7
/
> =
% - remainder
iS
!
Input : Read data from
memory [CRAMSJ or from an input device (keyboard/ disk)
Output : Display / write results to an output device (terminal/disk/printer)
↳
Read
new
( va r i a b l e temperature
:
: lay
Display variable/constant temperature
Initialize :
Using the SET statement in the pseudo language
>
-
SET <variable) TO < constant/variable
>
-
SET X TO 10
Compute
Using the COMPUTE statement in the pseudo language
>
-
COMPUTE <variable) A s expression >
>
-
COMPUTE X As
ytz
Flow Control One-way Branching :
-
IfThen .
One-way branching based on the condition
being TRUE
(number > 0
: If <Boolean-expression)
Display positive
Then
<
Statement/statements >
ENDIF
, Flow Control -
Two-way Branching :-
I f then-Else :
is based
Two-way branching on Condition being TRUE Or FALSE
Bortemperatureo
# If
day
The
stuisplay cod arents
ELSE
ants
Display , mid
ENDIF
Flow Control-Multi-way Branching :
Nested i f then-else multi
branching based &
:
way on condition being TRUE or FALSE more
temperature yo
: If <Brolean-condition) THEN
StaSPYcodasa
ELSE
If <Botmprature THE
< SESPLAYnota
sents
ELSE
DISPAYmidaySee n t
ENDIE
ENDIF
Iterations- WHILE Loop :
Initialization (optional (
-
Bookan Expression. Evaluate a Boolean expression
-
IF TRUE
· Execute a sequence of statements
-
Repeat
-
Set n to 3
Set sum to0
< initialization Statements >
:
n> 0
WHILE (Boolean
expression] -
COMPUTE Sum As S u m t n
statements if Boolean expression is true >
END SUBTRACT I FROMT
Iterations -
FOR
Loop :
-
Initialization. Evaluate an initiation statement
-
Boolean Expression. Evaluate a Boolean expression
-
EXTRUE . Execute a sequence of statements
Execute an increment statement
Repeat
-
For eachanyofthea we
Ex yofthece and
:
END FOR