0% found this document useful (0 votes)
38 views19 pages

Tle Reviewer

The document provides an overview of computational thinking and algorithms based on lessons from a quarterly reviewer. It defines computational thinking as a systematic approach to problem solving that can be understood by computers and people. Key concepts include decomposition, pattern recognition, and abstraction. An algorithm is defined as a set of precise instructions to perform a computation or solve a problem. Examples are provided of different algorithm types like divide and conquer. The document also discusses variables, data types, and constants in programming. Variables store and change data values, while constants do not change. Data types include boolean, integers, floating point, strings, and more.

Uploaded by

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

Tle Reviewer

The document provides an overview of computational thinking and algorithms based on lessons from a quarterly reviewer. It defines computational thinking as a systematic approach to problem solving that can be understood by computers and people. Key concepts include decomposition, pattern recognition, and abstraction. An algorithm is defined as a set of precise instructions to perform a computation or solve a problem. Examples are provided of different algorithm types like divide and conquer. The document also discusses variables, data types, and constants in programming. Variables store and change data values, while constants do not change. Data types include boolean, integers, floating point, strings, and more.

Uploaded by

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

T.L.

E 2ND QUARTER REVIEWER


LORAIN ANTONIL (8 - PASTEUR)
LESSON 1: Computational Thinking
● Computational Thinking is a systematic approach to solving problems.
● This involves understanding a problem and developing possible solutions that
can be understood by a computer, person, or both.
● The thought processes involved in formulating problems and their solutions so
that solutions are represented in a form that can be effectively carried out by
an information-processing agent.

3 key concepts of Computational thinking:


● Computational concepts
a) Sequence: identifying a series of steps for a task
b) Loops: running the same sequence multiple times
c) Parallelism: making things happen at the same time
d) Events: one thing causing another thing to happen
e) Conditionals: making decisions based on conditions
f) Operators: support for mathematical and logical expressions
g) Data: storing, retrieving, and updating values

● Computational practices
a) Experimental and iterating: developing a little bit, the trying it out,
then developing more
b) Testing and debugging: making sure things work - and finding and
solving problems when they arise
c) Reusing and remixing: making something by building on existing
project or ideas
d) Abstracting and modularizing: exploring connections between the
whole and the parts

● Computational perspectives
a) Expressing: realizing that computational is a medium of creation, “I
can create”
b) Connecting: recognizing the power of creating with and for others, “I
can do different things when I have access to others”
c) Questioning: feeling empowered to ask about the world.

ELEMENTS OF COMPUTATIONAL THINKING


● Decomposition: process of breaking problems down into smaller, more
manageable parts.
● Pattern recognition: process of looking for similarities across sets of
problems, or similarities within the problem itself. This can be applied to
solutions as well.
● Abstraction: process of removing unnecessary information and focusing on
the important details.
● Algorithm: a step-by-step or procedural representation of the solution to a
problem.

LESSON 2: ALGORITHM
● An algorithm is “a finite set of precise instructions for performing a
computation or for solving a problem”
● A program is one type of algorithm
- All programs are algorithms
- Not all algorithms are programs!

Algorithm 1: Maximum element


● Algorithm for finding the maximum element in a list:

procedure max (a1, a2, …, an: integers)


max := a1
for i := 2 to n
if max < ai then max := ai
{max is the largest element}

● Properties of algorithm
- Input: what the algorithm takes in as input
- Output: what the algorithm produces as output
- Definiteness: the steps are defined precisely
- Correctness: should produce the correct output
- Finiteness: the steps required should be finite
- Effectiveness: each step must be able to be performed in a finite
amount of time
- Generality: the algorithm should be applicable to all problems of a
similar form

● Basic steps to make an algorithm


- Step 1: Obtain a description of the problem.\
➢ the description relies on unstated assumptions,
➢ the description is ambiguous,
➢ (3) the description is incomplete, or
➢ (4) the description has internal contradictions
- Step 2: Analyze the problem.

- Step 3: Develop a high-level algorithm.

- Step 4: Refine the algorithm by adding more detail.


- Step 5: Review the algorithm.

Basics Steps to make an algorithm = computer programming:


● START: start the algorithm
● INPUT: take the input for values in which the algorithm will execute
● CONDITIONS: Perform some conditions on the input to get the desired output
● OUTPUT: printing the outputs
● END: end the execution.

Types of algorithm
● DIVIDE AND CONQUER ALGORITHM - divide the problem into smaller
subproblems of the same type; solve those smaller problems and combine
those solutions to solve the original problem.
1. Divide: Divide the given problem into sub-problems using recursion.
2. Conquer: Solve the smaller sub-problems recursively. If the
subproblem is small enough, then solve it directly.
3. Combine: Combine the solutions of the sub-problems that are part of
the recursive process to solve the actual problem.

● BRUTE FORCE ALGORITHM - try all possible solutions until a satisfactory


solution is found.
● RANDOMIZED ALGORITHM - use a random number at least once during the
computation to find a solution to the problem.
● GREEDY ALGORITHM - find an optimal solution at the local level with the
intent of finding an optimal solution for the whole problem.
● RECURSIVE ALGORITHM - solve the lowest and simplest version of a
problem to then solve increasingly larger versions of the problem until the
solution to the original problem is found.
● BACKTRACKING ALGORITHM - divide the problem into subproblems, each
which can be attempted to be solved; however, if the desired solution is not
reached, move backwards in the problem until a path is found that moves it
forward.
● DYNAMIC PROGRAMMING ALGORITHMS - break a complex problem into
a collection of simpler subproblems, then solve each of those subproblems
only once, storing their solution for future use instead of re-computing their
solutions.

LESSON 3: VARIABLES
● Variables in programing
- A variable can be set and changed while a program is running.
● What can a variable hold
- A variable is a placeholder in the memory of a computer. It can hold
one value at a time.
- Each variable in a program is named.
RULES
- a letter
- a combination of letters
- a combination of letter(s) and number(s)
- a combination of letter(s) and number(s) and underscore
Examples: A, sum, num12,
crush_mo_siya_1
Change a value
● If the value of a variable is changed, the new value replaces the
previous value.
● It’s time to change your values. Remember to remove the previous
values and destroy them!

Naming variables
● To help when programming, variable names should be short and unique.
They should contain underscores instead of spaces. For example,
Home_team

Types of variables:
● “Variables” are simply storage locations for data
● All operations on variables are performed with consideration of what the
variable's "Type" is
● There are rules that define what operations are legal in order to maintain the
integrity of the data you put in a variable
Primitive Data:
● There are eight primitive data types
● Four of them represent integers:
- byte, short, int, long
● Two of them represent floating point numbers:
- float, double
● One of them represents characters:
- char
● And one of them represents boolean values:
- boolean

1. BOOLEAN TYPE - Boolean types are declared using the keyword, bool
- They have two values: true or false
2. INTEGRAL TYPES
● An integral is a category of types.
● They are whole numbers, either signed or unsigned, and the char type
is a Unicode character, as defined by the Unicode Standard

3. FLOATING POINT AND DECIMAL TYPES


● A floating point type is either a float or double
● They are used any time you need to represent a real number
● Decimal types should be used when representing financial or money
values

4. STRING TYPE
● A string is a sequence of text characters.
● You typically create a string with a string literal, enclosed in quotes:
"This is an example of a string."
● Some characters aren't printable, but you still need to use them in
strings.

LESSON 4: CONSTANT
● CONSTANT
-Values that do not change while the program is running
-They are very effective when, for example, you have a number that you
want to use over and over again, you can simply use a constant name
instead of typing the numbers every time you need it.
- EXAMPLE:
Dollar = 45.50
Pi = 3.1416
Name= “Jhera”
School = “Santa Rosa Science and Technology High School”
● TYPES OF CONSTANT
- REAL OR FLOATING CONSTANT - Constants are fixed values that
do not change during the execution of a program. A real constant is a
combination of a whole number followed by a decimal point and the
fractional part. Example: 0.0083 -0.75 .95 215.
- USE OF REAL OR FLOATING-POINT CONSTANT - Integer numbers
are inadequate to represent quantities that vary continuously, such as
distances, heights, temperatures, prices and so on. These quantities
are represented by numbers containing fractional parts. Such numbers
are called real or floating point constants.
- The Real or Floating-point constants can be written in two forms:
A. Fractional or Normal form - A real constant consists of a series of
digits representing the whole part of the number, followed by a decimal
point, followed by a series representing the fractional part. The whole
part or the fractional part can be omitted, but both cannot be omitted.
The decimal cannot be omitted. That is, it is possible that the number
may not have digits before the decimal point or after the decimal point.

● RULES FOR CONSTRUCTING REAL CONSTANT IN FRACTIONAL FORM


1. A real constant must have at least one digit.
2. It must have a decimal point.
3. It could be either positive or negative.
4. Default sign is positive.
5. Commas or blanks are not allowed within a real constant.

B. Exponential or Scientific form - A real constant is a combination of a


whole number followed by a decimal point and the fractional part. If the value
of a constant is either too small or too large, an exponential form of
representation of real constants is usually used. In exponential form, the real
constant is represented in two parts.
- MANTISSA: The part appearing before e, the mantissa is either a real
number expressed in decimal notation or an integer.
- EXPONENT: The part following e, the exponent is an integer with an
optional plus or minus sign followed by a series of digits. The letter e
separating the mantissa and the exponent can be written in either
lowercase or uppercase.
- EXAMPLE:
★ 0.000342 can be represented in exponential form as 3.42e-4
★ 7500000000 can be represented in exponential form as 7.5e9 or
75E8
- STRING CONSTANT - A character string, a string constant consists of a
sequence of characters enclosed in double quotes.
★ A string constant may consist of any combination of digits, letters,
escaped sequences and spaces. Note that a character constant ‫ۥ‬A‫ۥ‬
and the corresponding single character string constant "A" are not
equivalent.
‫ۥ‬A ‫ۥ‬Character constant - ‫ۥ‬A‫ۥ‬
“A” - String Constant - ‫ۥ‬A’ and ‫ۥ‬0\ ‫( ۥ‬NULL)
★ The string constant "A" consists of characters A and \0. However, a
single character string constant does not have an equivalent integer
value. It occupies two bytes, one for the ASCII code of A and another
for the NULL character with a value 0, which is used to terminate all
strings.

RULES:
RULES
● A string constant may consist of any combination of digits, letters, escaped
sequences and spaces enclosed in double quotes.
● Every string constant ends up with a NULL character which is automatically
assigned (before the closing double quotation mark) by the compiler.

Numeric constants: There are two types of numeric constants: Integer constants
and Real or floating-point constants
Integer constants
- Any whole number value is an integer.
● An integer constant refers to a sequence of digits without a decimal point.
● An integer preceded by a unary minus may be considered to represent a
negative constant
Example: 0 -33 32767

There are three types of integer constants namely,


a) Decimal integer constant
b) Octal integer constant
c) Hexadecimal integer constant

● Decimal Integer constant (base 10)


It consists of any combinations of digits taken from the set 0 through 9,
preceded by an optional – or + sign.
● The first digit must be other than 0.
● Embedded spaces, commas, and non-digit characters are not permitted
between digits.

Valid: 0 32767 -9999 -23


Invalid: 12,245 - Illegal character (,)
10 20 30 - Illegal character (blank space)
Octal Integer Constant (base 8)
- It consists of any combinations of digits taken from the set 0 through 7.
- If a constant contains two or more digits, the first digit must be 0.
In programming, octal numbers are used.
Valid: 037 0 0435
Invalid: 0786 - Illegal digit 8
123 - Does not begin with zero
01.2 - Illegal character (.)

Hexadecimal integer constant (base 16)


- It consists of any combinations of digits taken from the set 0 through 7
andalso a through f (either uppercase or lowercase).
- The letters a through f (or A through F) represent the decimal quantities 10
through 15 respectively.
- This constant must begin with either 0x or 0X.
- In programming, hexadecimal numbers are used.
Valid Hexadecimal Integer Constant: 0x 0X1 0x7F

Invalid Hexadecimal Integer Constant: 0xefg - Illegal character g


123 - Does not begin with 0x

● Unsigned integer constant: An unsigned integer constant specifies only


positive integer value. It is used only to count things. This constant can be
identified by appending the letter u or U to the end of the constant.
Valid: 0u 1U 65535u 0x233AU
Invalid: -123 - Only positive value

● Long integer constant: A long integer constant will automatically be


generated simply by specifying a constant that exceeds the normal maximum
value. It is used only to count things. This constant can be identified by
appending the letter l or L to the end of the constant.

Valid: 0l23456L 0x123456L -123456l


Invalid: 0x1.2L - Illegal character (.)

● Short integer constant: A short integer constant specifies small integer


value. This constant can be identified by appending the letter s or S to the end
of the constant.

Valid: 123s -456 32767S


Invalid: 12,245 - Illegal character (,)
10 20 30 - Illegal character (blank space)
LESSON 5: PROGRAMMING
● What is programing
- It is a language for user and computer to understand each other
- Is the process of creating executable computer programs to perform a
specific task
- It is a set of instructions for a computer to understand and execute.
● What is Artificial Intelligence (AI)
- It is the simulation of human intelligence in machines that are
programmed to think, learn, and solve problems in the same way that
humans do.
- The goal of AI is to develop systems that can perform tasks that
normally require human intelligence.
● VARIABLES
- Variable is a name that refers to a value.
- To assign a value in a variable, an assignment operator must be used.
● DATA TYPES - consist of the categories of data.

● OPERATORS - are special symbols that represent computations like addition


and multiplication. The values the operators use are called operands.
- THERE ARE 3 TYPES OF OPERATORS:
1. Arithmetic Operators
2. Relational operator
3. Logical operator
1) ARITHMETIC OPERATOR - are symbols used in programming to perform
mathematical equations.
- Plus sign (+): used for concatenation and addition

- Minus sign (-); used for subtraction

● Relative Operators - are symbols used in programming to perform comparison


between two or more values that would return a Boolean value.
- The 6 Relative Operators include:
1) == (Equal Sign)
2) !=, <> (Not equal Sign)
3) < (Less than Sign)
4) <= (Less than or equal to Sign)
5) > (Greater than Sign)
6) >= (Greater than or equal to Sign)

● Logical Operators - are symbols used in programming to perform logical


operations on one or more Boolean values (True or False).
The 3 Logical Operators include:
1.) AND - returns True if both statements are true; otherwise, it returns
False.
2.) OR - returns True if at least one statement is true; otherwise, it returns
False.
3.) NOT - returns True if the statement is false; returns False if the
statement is true.
● Assignment Operators: In programming, allows us to change the
value of a modified data object (variable).
- Simple Assignment:
Age = 21
The value 21 is moved to the memory location for the variable
named: Age. Another way to say it: Age is assigned the value
21.
● Increment and decrement operators
➢ Increment operator: increases the value of a variable by 1
➢ Decrement operator: decreases the value of a variable by 1

LESSON 6:SYMBOLS IN FLOWCHART


● Flowchart
- It is a diagram that shows the sequence of steps or actions
needed to perform a process.
- A graphical representation of decisions and their results mapped
out in individual shapes.
- use special shapes or symbols to represent different types of
actions or steps in a process.

● ELLIPSE (START/END)
➢ it is represented by an ellipse.
➢ It appears at the start and the end of a flowchart.
➢ It only appears once in a given flowchart.

● PARALLELOGRAM (INPUT/OUTPUT)
➢ It is represented by a parallelogram
➢ It represents input or output.
● RECTANGLE (PROCESS)
➢ It is represented by a rectangle.
➢ It represents an individual step or activity in the process.
● DIAMOND (DECISION)
➢ It is represented by a diamond.
➢ It represents a process of decision that can be answered by YES or
NO.
● CIRCLE (CONNECTOR)
➢ It is represented by a circle.
➢ It indicates that a particular step or process is connected to another
page or part of a flowchart. It ensures the continuation of the process,
logically and accurately.
● ARROW (FLOW)
➢ It is the representation of the FLOW of the process. Keeping the
relation of processes clear.
➢ It is drawn, preferably, from top to bottom.

LESSON 7: PROGRAMMING LANGUAGES


● COMPUTER SYSTEM
- A computer is an electronic device that works under the control of
stored programs, automatically accepting, storing and processing data
to produce information that is the result of that processing. Thus a
computer system has hardware and software.
- Hardware describes all the electronic and mechanical elements of the
computer , together with those devices used with the computer.
- Software describes all the various programs that may be used on a
computer system together with their associated documentation.
- A program is a set of instructions that is written in the language of the
computer.
- A program is a set of instructions that is written in the language of the
computer. It makes the computer to perform a specific task
● COMPUTER LANGUAGES
- Computer languages allow programmers to develop computer
programs. Many different languages have been developed, each with
its own unique vocabulary, grammar, and uses.
● The Languages are categorized into 5 levels:
1. Machine Language( First Generation)
2. Assembly Language (Second Generation)
3. High Level Languages( Third Generation Languages- Procedural
Languages
4. Very High-Level Languages (Fourth Generation Languages-Problem-
Oriented Language)
5. Natural Languages- (Fifth Generation Languages).

1) first Generation Language (MACHINE LANGUAGE) :


The first generation languages are also called machine languages/ 1G
language. This language is machine-dependent. The machine language
statements are written in binary code (0/1 form) because the computer can
understand only binary language.
- Advantages :
a. Fast & efficient as statements are directly written in binary
language.
b. No translator is required.
- Disadvantages :
a. Difficult to learn binary codes.
2) Second Generation Language (ASSEMBLY LANGUAGE) :
● The second-generation languages are also called assembler
languages/ 2G languages. Assembly language contains human-
readable notations that can be further converted to machine language
using an assembler.
● Assembler – converts assembly level instructions to machine level
instructions.
● Programmers can write the code using symbolic instruction codes that
are meaningful abbreviations of mnemonics. It is also known as low-
level language.
- Advantages:
a. It is easier to understand compared to machine language.
b. Modifications are easy.
c. Correction & location of errors are easy.
- Disadvantages:
a. Assembler is required.
b. This language is architecture /machine-dependent, with a
different instruction set for different machines.

3) Third Generation Language (HIGH LEVEL LANGUAGE) :


● The third generation is also called procedural language /3 GL. It
consists of the use of a series of English-like words that humans can
understand easily, to write instructions. It's also called High-Level
Programming Language. For execution, a program in this language
needs to be translated into machine language using Compiler/
Interpreter.
- Examples of this type of language are C, PASCAL, FORTRAN,
COBOL, etc..

- advantages :
a. Use of English-like words makes it a human-
understandable language.
b. Lesser number of lines of code as compared to above 2
languages.
c. Same code can be copied to another machine &
executed on that machine by using compiler-specific to
that machine.
- Disadvantages :
a. Compiler/ interpreter is needed.
b. Different compilers are needed for different machines.

4) Fourth Generation Language (VERY HIGH-LANGUAGE): The fourth-


generation language is also called a non – procedural language/ 4GL. It
enables users to access the database.
- Examples: SQL, Foxpro, Focus, etc.
- These languages are also human-friendly to understand.
- Advantages :
a. Easy to understand & learn.
b. Less time required for application creation.
c. It is less prone to errors.
- Disadvantages :
a. Memory consumption is high.
b. Has poor control over Hardware.
c. Less flexible.

5) Fifth Generation Language (NATURAL LANGUAGE) : The fifth-generation


languages are also called 5GL. It is based on the concept of artificial intelligence. It
uses the concept that rather than solving a problem algorithmically, an application
can be built to solve it based on some constraints, i.e., we make computers learn to
solve any problem. Parallel Processing & superconductors are used for this type of
language to make real artificial intelligence.
- Example: PROLOG, LISP, etc.
- Advantages :
a. Machines can make decisions.
b. Programmer effort reduces to solving a problem.
c. Easier than 3GL or 4GL to learn and use.
- Disadvantages :
a. Complex and long code.
b. More resources are required & they are expensive too.

You might also like