0% found this document useful (0 votes)
14 views

CS Test 2

Uploaded by

Kyaw Myint Naing
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

CS Test 2

Uploaded by

Kyaw Myint Naing
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Computer Science TEST 2

Name

Time : 1 hour
Answer all questions.

1. The following statement are TRUE or FALSE. [10]


(i) Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the
adjacent elements if they are in the wrong order. TRUE
(ii) Conditional statement is a process that is repeated. For example, a document can be
checked and edited, checked and edited and so on until it is perfect. FALSE
(iii) The Merge Sort algorithm is a sorting algorithm that is based on the Divide and Conquer
paradigm. In this algorithm, the array is initially divided into two equal halves and then they
are combined in a sorted manner. TRUE
(iv) To use the binary search, that can be easily used on any lists without having to be
specially updated. FALSE
(v) Decomposition is usually the first step in the problem-solving process. Once a problem
has been broken down and the sub-problems have been identified, algorithms can be
developed to solve each of them. TRUE
(vi) Abstraction is used to remove unnecessary detail to make a problem easier to understand
and solve. For example, when modelling traffic flow in a city, unnecessary details could
include the colours of the vehicles or the ages of the drivers. TRUE
(vii) When designing a solution to a problem the inputs, outputs and processing requirements
should be identified at the outset. TRUE
(viii) . All high-level programming languages are like natural human languages, which makes
them not easier for humans to read and write but possible for computers to understand
without the help of a translator. FALSE
(ix) Type coercion is the process of converting the value stored in a variable from one data
type to another. TRUE
(x) A loop is another name for a switch. Loops are used to make a computer repeat a set of
instructions more than once. There are two types of loop: definite and indefinite. FALSE
2. A program needs to perform the following tasks:
• Input two numbers from the user
• Compare both numbers and output the largest number.
(a) Complete the pseudocode for this program. [5]
…………… ‘Please enter the first number’ ……………………………….
……………… num1 ……………………………………………………….
………………. ‘Please enter the second number’ ………………………….
……………….. num2 ………………………………………………………
……………….. num1 > ……………………….. then
………………………………………………………………………..
ELSE
………………………………………………………………………...
END IF
(b) Write a program code with Python for the above program. [5]
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
3. A program uses a file to store a list of words that can be used in a game.
A sample of this data is shown in the following table.
crime bait fright victory nibble loose
(a) Show the stages of a bubble sort when applied to data shown in the above sample table.[4]
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
(b) A second sample of data is shown in the following table. Show the stages of a binary
search to find the word zebra using that data. [4]
amber house kick moose orange range tent wind zebra
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
(c) A teacher researches the length of time students spend playing computer games each day.
Tick ( ) one box to identify the data type you would choose to store the data and explain
why this is a suitable data type. [2]
Data Type Tick ( ) one box
String
Integer
Real
Boolean
Explanation:
………………………………………………………………………………………….
…………………………………….………………………………………………….…
4. A program creates usernames for a school. The first design of the program is shown in the
flowchart in Figure.

For example, using the process in Figure, Tom Ward’s username would be TomWa.
(a) State, using the process in Figure, the username for Rebecca Ellis and Catherine
Earnshaw. [2]
…………………………………………………………………………………

…………………………………………………………………………………

(b) The program design is updated to create usernames as follows:


• If the person is a teacher, their username is the last 3 letters of their surname and
then the first 2 letters of their first name.
• If the person is a student, their username is the first 3 letters of their first name and
then the first 2 letters of their surname.
(i) What would be the username for two teachers called Fred Biscuit and Beck Pitt using the
updated process? [2]
…………………………………………………………………………………

…………………………………………………………………………………

(ii) Write a program code for the updated program design shown in question 4(b)(i). [6]
You must use either a high-level programming language that you have studied or
pseudocode.
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
……………………………………………………………………………………….
5. Match the following terms with related statements explanatory notes. (Write only alphabet)
[10]

(a) Linear search (b) subprogram (c) Merge sort (d) divide and conquer (e) initialise

(f) execution (g) abstraction (h) brute force (i) computational thinking (j) character
(i) An algorithm design that does not include any techniques to improve performance, but
instead relies on computing power to try all possibilities until the solution to a problem is
found. h
(ii) A sorting algorithm that divides a list into two smaller lists and then divides these until
the size of each list is one. Repeatedly applying a method to the results of a previous
application of the method. c
(iii) It is a simple algorithm and not very sophisticated. It simply starts at the beginning of the
list and goes through it, item by item, until it finds the item it is looking for or reaches the end
of the list without finding it. a
(iv) The process of removing or hiding unnecessary detail so that only the important points
remain. g
(v) An algorithm design that works by dividing a problem into smaller and smaller sub-
problems, until they are easy to solve. The solutions to these are then combined to give a
solution to the complete problem. d
(vi) The thought processes involved in formulating problems and their solutions so that the
solutions are represented in a form that can be effectively carried out by a computer. i

(vii) The processing can be split into parts. These separate algorithms could be used when
they are needed. It is efficient because it means that the same code doesn’t have to be
rewritten whenever it is needed. b

(viii) The process by which a computer carries out the instructions of a computer program.
f
(ix) A character can be a single letter, a symbol, a number or even a space. It is one of the
four basic data types. j

(x) When the program is run, to set variables to their starting values at the beginning of a
program or subprogram. e
2(a)

SEND TO DISPLAY

RECEIVE FROM KEYBOARD [1]

SEND TO DISPLAY

RECEIVE FROM KEYBOARD [1]

IF num2 [1]

SEND num1 TO DISPLAY [1]

SEND num2 TO DISPLAY [1]

(b) num1 = input('Please enter the first number ')

num2 = input('Please enter the second number ')

if num1 > num2:

print(num1)

else:

print(num2)

3(a) [4]

crime bait fright nibble loose


victory
bait crime fright nibble loose
victory
bait crime fright nibble victory loose

bait crime fright nibble loose victory

bait crime fright loose nibble victory

(b)[4]

 Comparing zebra to orange


 Greater, so split and take right side
 Further comparison (1 or 2 depending on choices made)
 Correct identification of zebra using methodology above

e.g.

compare zebra to orange

greater, split right


compare to wind

greater, split right

compare to zebra

(c) [2]

Integer (1)…

• …number of seconds not important (1)

• … level of accuracy not needed so round to nearest minute (1)

• …using a decimal to store seconds (0-60) is not appropriate (1)

Real (1)…

• … number of seconds may be important (1)

• … allows parts/fractions to be stored over integers (1)

One mark for appropriate data type identified.

One mark for appropriate justification linked to the data type chosen.

(a)[2] RebEl CatEa

(b) (i) [2] uitFr ittBe

You might also like