Preview

12 - GCSE (Prog&Algorithms)Part 2(Exam simulation)

 1. What is the following a definition for? "Break down a problem into a series of small sub-problems - break down those sub-problems into further sub-problems"

  Algorithm

  Modulation

  Abstraction

  Decomposition

 2. What is the following a definition for? "Solve a problem by removing unnecessary information/data. Example: The London Tube Map is an example of this."

  Modification

  Decomposition

  Algorithm

  Abstraction

 3. Describe what is meant by the term 'Algorithm'? (2 marks)

 4. Describe what is meant by a variable (2 marks)
Please consider the key words we are looking for. Hint: M_____ location and a value that c_________.

 5. Point out the variables in the following code.
x=2
y=3
flag=True
if flag==True:
  print(x+y)

  x only

   y only

  x,y and flag

  x and y

 6. Point out the programming constructs that have been used in the above code (2 marks)

 7. How would you describe what is occuring (refer to code above) on line 3 with the 'flag = True' statement?

  flag is a boolean variable that is set to 'True'

  flag is a string variable that has an integer value

  flag is a programming construct that is set to 'True'

  flag is a function that returns a value of 'True'

 8. Tom is creating a game that stores the names, scores and weapons for multiple players. Explain why it would be advantageous to use an array in this situation? (2 marks)

 9. It is important that code that is written is 'maintainable'. State four points that are important to consider in the maintainability of code (e.g. ensuring that the code is easy to maintain if it is handed over) (4 marks)

 10. Provide two benefits to programmers of using a function in a program. (2 marks)

 11. The following code makes use of constants. State one item in this program that could have been written as a constant.
01 int radius = 0
02 real area = 0.0 
03 input radius 
04 if radius < 1 OR radius > 30 then 
05 print (?Sorry, that radius is invalid?) 
06 else 
07       area = 3.142 * (radius ^ 2)  
08 print (area) 
09 end if 
 

  end if

  3.142

  radius

  invalid

 12. In reference to the code above,what would be considered a benefit of using a constant in a program?

  The number does not need to be changed while the program is running

  Once updated, the number would update throughout the program

  All of the statements listed here are valid answers

  The number can be updated once instead of several times

 13. Explain which line of code in the following snippet is incorrect, and why.
01 int radius = 0
02 int area = 0.0 

  Line 01, because radius is 0 and 0 should always be a real or float type.

  Both lines 01 and 02 are incorrect. Only a string variable can contain the number '0'.

  Both lines 01 and 02 are correct. They have declared variables and types correctly.

  Line 02, because area is clearly a real or float type variable (has a decimal)

 14. Programmers will typically use an IDE (integrated development environment) to do their coding. List five benefits or features of using an IDE (5 marks)

 15. The following explains how a binary logical left shift works. What should go in the yellow box? (the last box, on the second row of bits)
gcse_cert_paper2_part2_binaryshiftleft1.png

  Answer: 1

  Answer: x

  Answer: 0

  Answer: NULL

 16. Looking at the denary value, the initial byte has a value of 14. After shifting by 3, the new value is 112 (14x8). Shifting left by 3 is equivalent to _____________________________.
gcse_cert_paper2_part2_binaryshiftleft2.png

  dividing by 2.

  adding 2+2+2 (three 1 bit shifts)

  multiplying 2 x 3 (two three bit shifts)

  multiplying by 2x2x2 (three 1 bit shifts).

 17. Rhonda wishes to compress a file. Lossy compression means the decompressed file is not _______________ to the original. The difference is unlikely to be noticed by humans. Lossy also will ______ the file size. (2 marks)
Write the two words that fill in the blanks seperated by commas.

 18. Isaac uses his computer to record an audio file of himself playing his saxaphone Outline what happens when the computer converts the music into a file. (2 marks)

 19. Isaac increases the sample rate his computer is using to record his saxaphone. Explain two effects this will have on his sound recording. (2 marks)

 20. Isaac regularly uses library routines on his computer. Describe what is meant by a library routine (1 marks)

 21. What type of sort is being depicted in the diagram below? (1 mark)
typeofsort_paper2_cert_gcse_part2.jpg

 22. A _______ search looks for an item with a data set by starting with the first item in the set and comparing it to the search criteria. (1 mark)

 23. The following algorithm (pseudocode) is for a _____________________.
PROCEDURE sort(list,INPUT)
size = len(list)
	For i from 0 to size-1 DO
	If list[i] = INPUT
		OUTPUT Found item

list = Jim, Fred, Sue, Sheila
INPUT Enter item to search for
sort(list,INPUT)

 24. The code above has been edited (some code has been added) such that it will output a message if an item has not been found. What is missing from line 3?
PROCEDURE sort(list,INPUT)
size = len(list)
____________________________??(what goes here?)
	For i from 0 to size-1 DO
	If list[i] = INPUT
		OUTPUT Found item
		Found = True
	If Found = False
		OUTPUT Item not in list

list = Jim, Fred, Sue, Sheila
INPUT Enter item to search for
sort(list,INPUT)

  While Found ==True:

  While size < len

  Found = False

  While False = True:

 25. Read the following two 'advantages' and decide which of the following statements is true.
1. Easy to code, in comparison to other searching algorithms.
It can also be applied to unsorted lists.

2. Can find an item in a sorted list much quicker and
especially if the list is very long.

  Statement 1 is true of a linear search and Statement 2 is true of a Binary Search

  Statement 1 and 2 are both true of a binary search

  Statement 1 and 2 are both true of a linear search

  Statement 1 is true of a binary search and Statement 2 is true of a linear search

 26. What is the result of 12 MOD 3?

  Answer:2

  Answer: 3

  Answer:0

  Answer: 1

 27. The following algorithm takes a denary number (decimal number) and outputs the hex equivalent. Fill in the blanks for line 2.
INPUT decimal
_________________________________?
IF digit1>=10 THEN digit1=HEX(digit1)
digit2 = decimal ? (digit1*16)
IF digit2>=10 THEN digit2=HEX(digit2)

  digit1 = decimal MOD 16

  digit2 = input DIV 16

  digit1 = decimal DIV 16

  digit1 = decimal / 16

 28. Explain the difference between an interpreter and a compiler (2 marks)

 29. Read the following excerpt on the 'Merge Sort' and fill in the blanks.
When using merge sort to merge together 
[1, 3] and [2, 4] into ascending order, 
the algorithm will take the _____________
___________________________________________
 and place it into the new, merged list. 

This will then repeat meaning that the new 
list will be [1, 2, 3, 4]. It does not 
merge the lists to be [1, 3, 2, 4] 
and then sort this list.

  lowest value from the back of either list (in this case 1 or 2)

  lowest value from the front of either list (in this case 1)

  both the lowest and the highest value from both lists (in this case 1 and 4)

  highest value from the back of either list (in this case 4)

 30. Convert the binary number 11110011 to its hexadecimal equivalent.

 31. Convert the binary number 01010101 to its hexadecimal equivalent.

 32. There are two types of selection. If statements, and ______ (or switch) statements. The following code shows the use of _______ statements that would correctly fill in the blanks.
function returnDay(dayNo As String) As String
 switch dayNo
 _____ 0:
 returnDay = ?Monday?
 _____ 1:
 returnDay = ?Tuesday?
 _____ 2:
 returnDay = ?Wednesday?
 ______ 3:
 returnDay = ?Thursday?
 _______ 4:
 returnDay = ?Friday?
 ________ default:
 returnDay = ?Invalid?
 endswitch
endfunction

  select

  best

  iterate

  case

 33. The following code makes use of string manipulation to slice a string as well as concatenation (putting two strings together). The input is "Hannah" and "2016". If part1 ='an'. What is the final username that is output?
#Username Generator
name=input("Enter name:")
date_of_birth=input("Enter date of birth")
part1=name[1:3]
part2=date_of_birth[2:4]
print("Username:",part1+part2)

 34. In the adapted code below, the while loop continually asks the user to enter their name and date of birth. What alternative to line 9 could be added to the code to stop the loop once the username is printed?
#Username Generator
valid=False
while valid==False:
  name=input("Enter name:")
  date_of_birth=input("Enter date of birth")
  part1=name[1:3]
  part2=date_of_birth[2:4]
  print("Username:",part1+part2)
  break

  Line 9 could be: For 0 to 1 (this would run the code only once)

  Line 9 could be: value = False (to break out of the loop)

  Line 9 could be: valid=True (to break out of the loop)

  Line 9 could be: 'Return' to return to the start and stop the loop

 35. The following are in the correct order (ascending size)
bit , nibble, byte, GB, MB, PB, TB

  FALSE

  TRUE