H446/2 Exam Prep - Q2 Search

H446/2 Exam Prep - Q2 Search

12th Grade

8 Qs

quiz-placeholder

Similar activities

Arrays

Arrays

12th Grade

10 Qs

Practice for 10th AP Java quiz (old)

Practice for 10th AP Java quiz (old)

10th - 12th Grade

11 Qs

Search and Sorting Algorithms

Search and Sorting Algorithms

12th Grade

10 Qs

Microsoft Programs

Microsoft Programs

9th - 12th Grade

12 Qs

DASAR  KOMPUTER - FAOZAN AFANDI

DASAR KOMPUTER - FAOZAN AFANDI

12th Grade

11 Qs

Modular Programming & Algorithmic Strategies

Modular Programming & Algorithmic Strategies

12th Grade

10 Qs

Arrays and Lists

Arrays and Lists

6th - 12th Grade

10 Qs

AP CS A Unit 6 Quiz PRACTICE

AP CS A Unit 6 Quiz PRACTICE

9th - 12th Grade

10 Qs

H446/2 Exam Prep - Q2 Search

H446/2 Exam Prep - Q2 Search

Assessment

Quiz

Computers

12th Grade

Easy

Created by

RHSC Computing

Used 6+ times

FREE Resource

8 questions

Show all answers

1.

FILL IN THE BLANK QUESTION

1 min • 1 pt

2(a). A computer program stores data in an array named words.

The data in the array needs to be searched for a value that the user inputs.

      i.        One example of a searching algorithm is a binary search.

Identify the precondition for a binary search.
The array/data must be

Answer explanation

A few candidates were too vague giving unqualified answers such as ‘must be sorted’, without specifying what had to be sorted.

The array/data must be in order/sorted

2.

REORDER QUESTION

1 min • 4 pts

      i.        A second example of a searching algorithm is a linear search.
Describe how a linear search works.

  Compare the search item with the first value

the end of the array has been reached or

the search item is found

return the array position or -1/flase

then compare the search item with the next value

repeat the above process until either

Answer explanation

1 mark per bullet

  1. 1-Compare the search item with the first

value

2-….then compare the search item with

the next value

3-repeat the above process until either

4….the end of the array has been

-reached or

5-the search item is found and then

stop

6-….then return the array position //

return -1 / False if not found

3.

HOTSPOT QUESTION

1 min • 2 pts

The pseudocode function useWords() here uses the global array words. The number of words in the array words is passed as a parameter.

      i.        Identify two variables in the function useWords().

Answer explanation

1 mark for each variable

contents

count

numberOfWords

words / words[]

Do not award numberOfWords if there are

obvious spaces in ‘number of Words’. It

must be a valid identifier

4.

DRAG AND DROP QUESTION

1 min • 1 pt

Media Image

numberOfWords is a parameter passed by value. Describe the difference between passing a parameter by value and by referenceBy ​ (a)   the function receives the ​ (b)   location of the data By ​ (c)   the function receives a ​ (d)   of the variable

reference
memory
copy
value
pointer
address
location
instance
object

Answer explanation

1 mark per bullet

By reference the function receives the

memory location of the data

By value the function receives a copy

of the variable

By reference will make changes to the

original variable

By value will make changes to the copy

of the variable

By reference will overwrite data in the

original variable

By value will not overwrite the data in

the original variable

By reference will keep the changes

after the function ends

By value will not keep the changes

after the function ends

5.

DRAG AND DROP QUESTION

1 min • 1 pt

Media Image

Rewrite the function using a while

contents = ""

count = 0

​ (a)   count ​ (b)   numberOfWords

  contents = contents + ​ (c)   [count] + " "  

count = count + 1

endwhile

​ (d)   content

repeat
while
do
<
words
word
return
print

6.

CLASSIFICATION QUESTION

3 mins • 1 pt

Identify benefits and drawbacks of declaring an array as a global variable instead of a local variable.

Groups:

(a) Benefit

,

(b) Drawback

Alterations within the function may have unwanted side effects elsewhere in the program

Can be accessed from any function / anywhere in the program

Increases memory usage (as it is used until full program execution is over)

Variable doesn’t need passing as a parameter (byref)

You don’t need to return a value

Answer explanation

Drawbacks were poorly described.

Potential side effects and resultant

complexity debugging were frequently

alluded to as ‘accidental change’ but not

fully developed into complete qualified

points.

There was also a frequent misconception

that you cannot have multiple variables

with the same name, which is not true.

When a local variable is declared with the

same name as a global variable that

already exists, it takes precedence within

the local scope.

7.

CLASSIFICATION QUESTION

3 mins • 1 pt

Identify features of an Integrated Development Environment (IDE) that can be used to help write a program and one feature that can be used to help test a program.

Groups:

(a) Write a program

,

(b) Test a program

Auto-indent

Breakpoints

Stepping

Variable watch window

syntax highlighting

Auto-complete

Answer explanation

1 mark per identification 1 mark for

expansion, max 2 each.

Write:

e.g.

Auto-complete

Start typing an identifier/command and

it fills in the rest

Auto-indent

Indents code automatically within

structures to avoid errors

Coloured command words // pretty

printing // syntax highlighting

Shows which commands are correct //

help identify key elements

Test

e.g.

Breakpoints

Stop the program running at a set point

to check variables

Variable watch window

Display the values of the variables

while the program is run

Stepping

Run one line at a time and check

variables

Unit Testing

Automated tests to be run to check

changes ensure changes haven’t

introduced errors

8.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Functions and procedures are reusable components. Give two benefits of writing a program with reusable components

Saves time from having to write the same algorithm repeatedly

Increased testing requirements

Cannot be taken and used in different programs as well as the program they are written in

can be used in a program library

Discover more resources for Computers