H446/2 Exam Prep - Q2 Search

Quiz
•
Computers
•
12th Grade
•
Easy
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-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.
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
Similar Resources on Wayground
10 questions
PENILAIAN HARIAN 2

Quiz
•
11th Grade - University
12 questions
Microsoft Programs

Quiz
•
9th - 12th Grade
10 questions
CS Python Fundamentals 8.8 Lesson Quiz

Quiz
•
9th - 12th Grade
10 questions
Search engines

Quiz
•
1st - 12th Grade
10 questions
AP CS A Unit 6 Quiz PRACTICE

Quiz
•
9th - 12th Grade
9 questions
C++ Quiz 5: Searching and Sorting Algorithms

Quiz
•
7th - 12th Grade
13 questions
Lesson 5 - Searching the Web Quiz

Quiz
•
6th Grade - University
12 questions
Enumeration and Recursion

Quiz
•
11th Grade - University
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade