
H446/2 Exam Prep - Q2 Search
Authored by RHSC Computing
Computers
12th Grade
Used 6+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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.
return the array position or -1/flase
then compare the search item with the next value
the end of the array has been reached or
the search item is found
repeat the above process until either
Compare the search item with the first value
Answer explanation
1 mark per bullet
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
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
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
Rewrite the function using a while
contents = ""
count = 0
(a) count (b) numberOfWords
contents = contents + (c) [count] + " "
count = count + 1
endwhile
(d) content
6.
CATEGORIZE 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
You don’t need to return a value
Increases memory usage (as it is used until full program execution is over)
Can be accessed from any function / anywhere in the program
Variable doesn’t need passing as a parameter (byref)
Alterations within the function may have unwanted side effects elsewhere in the program
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.
CATEGORIZE 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
Variable watch window
syntax highlighting
Auto-indent
Stepping
Breakpoints
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?