0% found this document useful (0 votes)
11 views25 pages

Computer Science Theory Paper 2

The document provides definitions and explanations of key computer science concepts related to programming, including programming terms, program development lifecycle, data types, algorithms, file handling, functions, databases, and validation/verification processes. It covers essential programming structures such as loops, conditional statements, and data storage techniques like arrays. Additionally, it discusses the importance of testing and validation in ensuring the accuracy and functionality of programs.
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)
11 views25 pages

Computer Science Theory Paper 2

The document provides definitions and explanations of key computer science concepts related to programming, including programming terms, program development lifecycle, data types, algorithms, file handling, functions, databases, and validation/verification processes. It covers essential programming structures such as loops, conditional statements, and data storage techniques like arrays. Additionally, it discusses the importance of testing and validation in ensuring the accuracy and functionality of programs.
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/ 25

Computer Science Definitions P2

(This is the theory part related to Paper 2!)


By: Morx / Morxgy 5/17/2025

General Programming Terms


1: Program:
It is a list of instructions that do a specific task, and it can be
written in high-level language or low-level language.
2: Pseudocode:
A method that uses English words and mathematical notations to
design the steps of a program.
3: Flowcharts:
Diagram that designs the steps of a program by using a standard
set of symbols joined by lines to show the direction flow.
4: Trace Table:
It’s a table that can be used to record the results from each step in
an algorithm.
It is used to record the value of a variable each time it changes.
Used to document the dry run of a program.
5: Tracing (Dry run):
The manual exercise of working through an algorithm step by step.
6: Variable:
A named data store that contains the value that can be changed
during the execution of a program.

7: Constant:
A named data store that contains the value that does not change
during the execution of a program.
8: Comments:
They are blocks of texts in the pseudocode that are not executed
and used to explain the code.
9: Features of a maintainable program:
Use comments to explain the purpose of each section in the code.
Use meaningful identifiers names to clearly identify the purpose of
variables, constants, arrays, procedures and functions.
Use procedures and functions to avoid repeated code and simplify
logic.
Use indentation and white space to make the program readable.
10: Component parts after decomposition:
Inputs: The data that needs to be entered into the system.
Processes: The tasks that need to be performed using the input
data and any previously stored data.
Outputs: Information that needs to be displayed or printed for the
users.
Storage: Data that needs to be stored in files for use in the future.
11: Top-Down design
The breaking of a computer system into set of sub-systems and
then breaking each sub-system into a set of smaller ones until each
sub-system performs a single action.
Stepwise refinement definition:
It is the process of breaking down into smaller sub-systems.
Module definition:
An individual section of a code that can be used by other programs.
12: Structure Chart // Structure Diagram:
Diagram that shows the design of a computer system in a hierarchal
way, with each level giving a more detailed breakdown of the
system.
It’s purpose is to provide an overview of the system hierarchy and
to provide an overview of how the problem is broken down.
13: Ways to represent an algorithm:
Flowcharts
Pseudocode
Structure Diagrams // Structure Charts
14: Basic concepts to use when developing a program:
Data use – variables, constants and arrays.
Sequence – order of steps in a task
Selection – choosing a path through a program
Iteration – repetition of a sequence of steps in a program
Operator use – arithmetic operations for calculation and logical and
Boolean operators for decisions.

Program Development Lifecycle

15: Stages of Program Development Lifecycle:


Analysis:
Identification of the problem.
May include breaking down the problem into smaller parts.
Includes abstractions. (Removal of details).
Design:
Drawing flowcharts to solve the problem.
Writing pseudocode statements to solve the problem.
Decomposing the problem into smaller parts using structure
diagrams.
Coding:
Writing program code solution.
May include early testing.
Testing:
Testing the program code using test data.
Tasks performed in analysis:
Abstraction.
Decomposition.
Identification of the problem and requirements.
Abstraction definition:
Simplifying the problem.
Selecting elements required.
Filtering out irrelevant characteristics from those elements.
Decomposition definition:
Breaking down a complex problem into smaller parts which can be
divided into even smaller parts that can be solved easily.
Tasks performed in design:
Decomposition.
Structure diagrams.
Flowcharts.
Pseudocode.
Tasks performed in coding:
Writing program code.
Iterative testing.
Iterative testing definition:
Tests are conducted to each sub-system of the program, where
errors detected are corrected. Tests are repeated until the sub-
system performs as required.
Tasks performed in testing:
Testing a program code using test data.
Testing definition:
The completed program or set of programs is run many times with
different sets of test data to ensure all completed tasks work
together as specified in the program design.
16: Operators:
Operators’ definition and purpose: A special character or word in
programming that identifies an action to be performed.
Arithmetic Operators definition and purpose: Operators that are
used to perform calculations in the program.
Logical Operators definition and purpose: Operators that allow the
computer to decide whether an expression is true or false.
Boolean Operators definition and purpose: Operators that are used
with logical operators to form a more complex expression.
17: Program data types:
Integer: A positive or negative whole number that is used in
mathematical operations. Examples: 150, -1233
Real: A positive or negative number that has a fractional part that
can be used in mathematical operations. Examples: 11.3, -23.4
Char: A single character from the keyboard. Examples: A, C
String: A sequence of characters. Examples: I love computer science,
[email protected]
Boolean: Data with two possible values. Examples: (TRUE/FALSE),
(Y/N)
18: Sequential statements:
Statements are executed one after another according to their order.

19: Assignment statements:


A statement that changes the value of a variable or an element in an
array.
Examples: Total <- 22
(This sets the value of the variable “Total” to 22.)

20: Prompt Message:


An output message that is displayed before the user input any data
because it states the input required.
Its purpose is to help the user with what to input.

21: Conditional/Selection statements:


Selective statements are executed depending on meeting certain
criteria.
Its purpose is to allow different paths through a program depending
on meeting certain criteria.
22: IF..THEN..ELSE..ENDIF:
A conditional structure with different outcomes for true and false.
It’s purpose is to allow for checking complex conditions.

23: CASE..OF..OTHERWISE..ENDCASE:
A conditional structure that allows selection to be made based on
the value of a variable.
It is used to test for a large number of discrete values.

24: Iterative/Repetition statements:


One or more statements are repeated till a test condition is met or
while a test condition is TURE!!!
Its purpose is to repeat the same code a number of times, which
allows for a shorter code.
Types:
Count-controlled loops
Pre-condition controlled loops
Post-condition controlled loops
25: FOR..TO..NEXT (Count-controlled loop):
A loop structure that iterates a set number of times and it is used
when a set number of iterations are required.

26: WHILE..DO..ENDWHILE (Pre-condition loop):


A loop that iterates while a specified condition exists
Criteria is pre-tested (It has criteria check at the start)
It may never run.

27: REPEAT..UNTIL (Post-condition loop):


A loop that iterates until a condition is met.
Criteria is post-tested (It has criteria check at the end)
It has to iterate at least once.
Differences between REPEAT..UNTIL and WHILE..DO..ENDWHILE:
In WHILE the criteria is pre-tested but in REPEAT..UNTIL the criteria
is post-tested.
WHILE may never run while REPEAT.. UNTIL runs at least once.
WHILE iterates while a condition is TRUE but REPEAT..UNTIL iterates
until a condition is true.
28: Standard methods of solution:
Totaling.
Counting.
Finding the Maximum/Minimum value.
Finding the Average value.
Searching using Linear Search.
Soring using Bubble Sort.
29: Totaling:
The process of summing up a list of numbers.
Example: Total <- Total + Number

30: Counting:
The process of finding how many items are in a list.
Example: Count <- Count + 1

Arrays
31: Array:
A data structure that holds several elements of the same data type.
Its purpose is to store multiple values under the same identifier
making the code shorter and allows for simpler programming.
Index definition:
It is the position of an element in an array.
Dimension definition:
The number of indexes required to access an element in an array.
32: One-dimensional (1-D) array:
A list / one column of items
… of the same data type
… stored under a single name/identifier
… with a single index to identify each element stored in it.
Purpose of using arrays:
Makes the program easier to design/code/test/understand.
Code will be more compact.
Code will be more organized.
Less likely to make errors.
Declaring a 1D array:
DECLARE Numbers : ARRAY[1:10] OF INTEGER
OR
DECLARE Numbers[1:10] : INTEGER
33: Two-dimensional (2-D) array:
A table-like collection of items
… of the same data type
… has row and columns
… stored under a single name/identifier
… with two indexes to identify each element
Declaring a 2D array:
DECLARE Marks: ARRAY[1:10, 1:3] OF INTEGER
OR
DECLARE Marks[1:10, 1:3] : INTEGER
Linear Search and Bubble Sort

34: Linear Search:


The process of finding a value within a list of elements
Steps:
Loop over a list of items starting with the first element and finishing
with the last element.
Compares each element with the search value…
… if it is equal to the search value, set a flag to TRUE
… if it is not, then move to the next element
After iterating over all the elements the flag shows whether the
element is found or not.
35: Bubble Sort
The process of sorting a list of items either in alphabetical order or
using numerical values.
Steps:
Loops over a list of items starting with the first and finishing with
next-to-last element.
Each element is compared with the next element.
… swaps the elements if the elements are in the wrong order.
… after reaching the last element, the last element is now in the
correct position.
This is repeated a number of times equivalent to the number of
elements in the list…
… to ensure that all elements are in their correct position.

File Handling
36: Purpose of using files:
Data is not lost when the computer is switched off (data is stored
permanently).
Data can be used by more than one program or reused when a
program is run again.
Data can be transported from one computer to another.

Functions and Procedures

37: Subroutine:
Sub-program
Used to perform a frequently used operation within a program
Given a name and can be called when needed
Can be reused by another program
Written in high-level language
Purpose of using subroutines(functions/procedures):
To enable the programmer to write a collection of programming
statements under a single identifier.
To allow procedures to be re-used within the program or in other
programs.
To enable different programmers to work on different procedures in
the same project.
To make programs easier to maintain due to program code being
shorter.
38: Function:
A subroutine that always returns a value.
39: Procedure:
A subroutine that doesn’t always return a value.
40: Function/Procedure definition:
Setting-up the function/procedure
Includes defining the:
Function/Procedure name
Parameter names and data types
In case of a functions, the return data type.
Done only once. (Doesn't need to be redefined every time the
function is used.)
41: Function/Procedure call:
Using/executing the function code with parameters values.
Can be done multiple times.
Difference between function/procedure definition and
function/procedure call:
Defining is done once, calling can be done multiple times.
Defining is setting up the function/procedure and calling is using
the function itself.

Describe what happens when a function is called during the


execution of a program:
A call statement is used in order to make use of a function.
Parameters are passed from the main program to the function.
The function performs its task..
.. and returns a value to the main program.
42: Local variable:
A variable that is defined inside the scope of a subroutine.
Its scope is restricted to the part of the program where it was
defined.
Can be accessed only within the scope of the subroutine where it
was defined.
43: Global variable:
A variable that is defined outside the scope of a subroutine.
Its scope covers the whole program.
Can be accessed outside any function and from inside the scope of
any function.
Differences between local and global variables:
For local variables, the scope is a defined block of code
(function/procedure)…
… while global variables the scope is the whole program.
For local variables, value cannot be changed elsewhere in the
program…
… while global variables the value can be changed anywhere.
44: Parameter:
It’s a variable that is used to pass values from the main program to
a subroutine (function/procedure)
Its purpose:
To pass values from the main program to a procedure/function
… so that they can be used in the procedure/function
Allow the procedure/function to be re-used with different data.
45: Return value:
A value that is passed from inside a function to the main program.
46: Library routines:
It is a list of programming instructions that is:
Given a name
Already available to use
Pre-tested
Benefits of using library routines:
Library routines make writing programs easier and faster as the
code is already written.
They make testing the program easier as the code has been tested
and debugged.
Immediately available for use // They are readily available / speed
up development time.
It can perform a function that users may not be able to program.

Library routines:
ROUND:
Returns a value rounded to a specified number of digits.
The result will either be rounded to the next highest or the next
lowest value…
… depending whether the value of the preceding digit is >=5 or
<5
Example: ROUND(4.56, 1) = 4.6
RANDOM:
Generates (pseudo) random numbers
… within a specified range
Example: RANDOM() * 10
(returns a random number between 0 and 10)
DIV:
Performs an integer division of two numbers…
… with the fractional part discarded
Example: DIV(9,4) = 2
MOD:
Performs an integer division when one number is divided by
another
… and find the remainder
Example: 7 MOD 2 = 1

Databases
46: Database:
A structured collection of related data that allows people to extract
information in a way that meets their needs.
48: Purpose of SQL keywords:
Purpose of SELECT: An SQL command that identifies the fields to be
displayed.
Purpose of FROM: An SQL command that identifies the table to use.
Purpose of WHERE: An SQL command that identifies the search
criteria // An SQL command to include only the records that match
a given condition
Purpose of ORDERBY: An SQL command that sorts the result of the
query by a given column
Purpose of SUM keyword in SQL: An SQL command that returns the
sum of all values in a field
Purpose of COUNT keyword in SQL: An SQL command that counts
the number of records returned by the query.
49: Database terms:
Table: A collection of related records
Example: Table of students
Field: A column that contains one specific piece of information and
has one data type.
Examples: Student name / Student ID / Age / Address
Field Name: Title given to each field
Record: A row within a table that contains data about a single item,
person or event.
Primary Key: A field that contains unique data and can’t have
duplicates.
Example: Student ID field

Validation and Verification


50: Validation:
The automated checking by a program that makes sure that the
data entered is sensible.
Examples of validation checks:
Type check: Checks that the data entered has the appropriate data
type.
Example: A person’s age should be a number not text.
Presence check: Checks that some data has been entered and the
value has not been left blank.
Example: An email address must be given for an online transaction.
Range check: It checks that only numbers within a specified range
are accepted.
Example: Exam marks between 0 and 100 inclusive.
Length check: It checks that data contains an exact number of
characters.
Example: A password with exactly 8 characters in length.
Format check: It checks that the characters entered conform to a
pre-defined pattern.
Example: A company with IDs that start with MS then three numbers
would have a format of MS###
Check digit: A digit that is calculated from all the other digits and
appended (added) to the number
Example: Used in barcodes.
52: Verification:
Checking that the data has not changed during input to a computer
or during transfer between computers.
Its purpose is to ensure the accuracy of the transcription.
Types:
Visual/Screen Check.
Double Data Entry.
53: Screen/Visual Check:
Data is compared visually with the source document by a user.
The user is asked to confirm that the data entered is the same as
the original in the source document.
If the user finds a difference, the data is re-entered.
Double Data Entry:
Data is entered twice.
A computer checks that both entries are equal.
If they aren’t equal, an error message is output requesting to re-
enter the data displayed.

Testing data
Data is used to check that a computer responds correctly to correct
and incorrect values.
Purpose:
Checks that the program works as expected.
Check for errors.
Check that the program rejects any invalid data that is input.
Check that the program accepts sensible and reasonable data.

Types of test data:


Normal data: Correct data that should be accepted
Examples: The month can be any whole number in the range of 1 to
12.
Abnormal data: Data that is outside the limits of acceptability, or
wrong type of data, and should be rejected.
Examples: All the following values are not allowed as inputs for the
month -> Negative numbers, any value greater than 12, letters or
non-numeric data, non-integer values (e.g. 2.5/10/75)
Extreme data: Largest/smallest acceptable data and should be
accepted.
Examples: The extreme values of month can be either 1 or 12.
Boundary data: The largest/smallest acceptable value and
corresponding smallest/largest rejected value
Examples: The extreme values of month can be either 1 or 12.
The boundary rejected values of month can be 0 and 13.

Digital Logic

56: Logic gate:


A small physical device that controls the flow of electrical signals in
a pre-determinant way.
Its purpose:
To carry out logical operation.
To control the flow of electricity through a logic circuit.
To alter the output from given inputs.
Why is data stored as binary in computers?
Computers use logic gates
Logic gates use one of two values: 0 or 1.
Types of logic gates:
NOT
AND
OR
XOR
NAND
NOR
Purpose of NOT gate:
It has one input
Output will be 1 if the input is 0
Output will be 0 if the input is 1
Purpose of AND gate:
It has two inputs
Output will be 1 if both inputs are 1
Output will be 0 if either input is 0
Purpose of OR gate:
It has two inputs
Output will be 1 if either input is 1
Output will be 0 if both inputs are 0
Purpose of XOR gate:
It has two inputs
Output will be 1 if both inputs are different
Output will be 0 if both inputs are 0
Output will be 0 if both inputs are 1
Purpose of NAND gate:
It has two inputs
Output will be 1 if either input is 0
Output will be 0 if both inputs are 1
Purpose of NOR gate:
It has two inputs
Output will be 1 if both inputs are 0
Output will be 0 if either input is 1

You might also like