Font size
WorksheetsQuestion Bank for Grade 14 Computers
Total questions: 115
Worksheet time: 58mins
Which of the following are true statements about the binary search process? Check all that apply.
The average case scenario Big O running time is O(log N).
The target value must be contained within the list.
The process checks the middle item for a match, and then looks to the right or to the left if it doesn't match, repeating this process until a match is found, or not.
The precondition is that the list must be sorted.
Which of the following is considered an O(N log N) class sort for a worst case scenario?
Insertion Sort
Merge Sort
Selection Sort
Quick Sort
Which of these would be considered the worst case scenario for a linear search?
The target value is not found in the list.
The target value is found at the end of the list.
The target value is found at the beginning of the list.
The target value is found somewhere in the middle of the list.
Consider a list that contains eight integer values. If the list is sorted using the merge sort, how many total division operations will take place during the entire process?
(a)
Which of the following describes a selection sort?
The "best value for each position" is found and swapped into place with each pass.
The list is partitioned around a pivot point.
Unsorted values are shifted into their "best position" in the list.
Adjacent values are compared and swapped if out of order.
Which of the following descriptions of the Big O analysis categories is NOT correct?
An O(N log N) process is characterized by a divide and conquer process combined with an N based loop.
An O(N2) process is characterized by a nested loop process based on the size of the data set.
An O(1) process only works on a data set of 100 items or less.
An O(N) process is characterized by a loop that spans the entire data set of size N.
Consider a list:
{ 3, 5, 8, 10, 14, 34, 78, 123, 513, 999 }
If a binary search for the value 34 is performed, how many comparison operations will be required to find it?
3
1
6
5
Assume there is a function defined swap( pass-by-reference int [] list, int position1, int position2 ) which swaps values in the array list at index position1 and index position2. What sorting routine is represented by the code shown?
Bubble
Selection
Merge
Quick
Insertion
Consider a list:
{ 9, 2, 6, 8, -3, 7, 2, 15, 0, -1, 14, 99, -1 }
If a linear search for the value -1 is performed, what will be returned?
10
9
12
-1
Consider a partially sorted list that is undergoing the insertion sort in ascending order, with the first four values already in sorted order:
{ 1, 5, 6, 7, 4, 2, 3 }
How many shifts must be performed to insert the value 4 into the correct position?
2
1
4
3
Consider the following list:
{ 1, 6, 7, 4, 3, 9, 2, 5, 8 }
If the entire list is undergoing the initial partitioning pass using a quick sort process, with the middle value as the pivot, what will the list look like after the first pass?
{ 1, 2, 3, 4, 7, 9, 6, 5, 8 }
{ 1, 2, 7, 4, 3, 9, 6, 5, 8 }
{ 1, 6, 4, 3, 7, 2, 5, 8, 9 }
{ 1, 6, 7, 4, 3, 9, 2, 5, 8 }
A sort algorithm finds the best place in an already sorted portion of the list for the next unsorted item. Which sort algorithm best fits this description?
insertion sort
merge sort
selection sort
quick sort
Consider the following array, partially sorted using a selection sort process.
{ 0, 1, 2, 4, 5, 7, 3, 6 }
If elements have been correctly selected for the first three positions, what will the array look like after the next pass?
{ 0, 1, 2, 3, 5, 7, 4, 6 }
{ 0, 1, 2, 3, 5, 4, 6, 7 }
{ 0, 1, 2, 3, 4, 5, 7, 6 }
{ 0, 1, 2, 3, 5, 6, 4, 7 }
Consider the following array:
{ 0, 1, 6, 4, 2}
In how many passes will an ascending order bubble sort be accomplished?
5
2
3
4
Consider the partial pseudocode for a sort shown:
Which sort is this code most likely to represent?
quick sort
selection sort
insertion sort
merge sort
Consider this partial pseudocode segment for a quick sort, given a lo and hi index representing the inclusive bounds of the partition to be sorted.
What is the purpose of the if statement in this pseudocode?
The if statement detects that the entire list has been sorted and ends execution.
The if statement detects a pivot value and returns it.
The if statement detects new bounds of a partition and returns it.
The if statement detects a section of the list that is too small to partition any further and ends execution for that part of the process.
For a list of 1000 elements, using a process that is considered to have an O(log N) running time in all situations, what value below represents the maximum number of steps it will take for the algorithm to complete its task?
1000
10
500
1
Which of the statements below is NOT correct regarding the class definition shown?
The methods defined in lines 13 through 16 are accessor methods
The method defined in lines 7 and 8 controls the construction of a StudentInfo object
Lines 2 and 3 contain private instance field declarations
The methods defined in lines 9 through 12 are mutator methods
Using the class definition and client code shown above, which of the following is NOT a valid client code statement for line 20?
print s.toString()
print s.age
s.setAge(24)
print s.getAge()
Which choice below best describes the situation where the running time of a binary search is O(1)?
When the target value being searched is found in the middle of the list.
When the target value being searched is not found.
When the target value being searched is found at the beginning of the list.
When the target value being searched is found at the end of the list.
The adjacency matrix of a 4-node graph is given below. How many direct connection paths exist in the graph that is represented by this matrix?
(a)
Which choice below is best described by the following statement?
Linear data structure contained in static, contiguous memory, where all items can be easily assigned and accessed using an indexing process, allowing for quick and easy data management.
Queue
Stack
Array
Tree
Graph
After the integer elements 5, 3, 7, 1, 2, 4 are correctly inserted into a minimum heap tree, with the value 5 as the initial root, which choice below represents the pre-order traversal of the tree?
1 2 3 4 5 7
5 2 3 1 7 4
5 3 2 7 4 1
1 2 5 3 4 7
After the integer elements 5, 3, 7, 1, 2, 4 are correctly inserted into a binary search tree, and the value 6 is then added to the tree, which statement below best describes the resulting position of the node that contains the 6?
Left child of 1
Root node
Right child of 4
Left child of 7
If a linked list contains N elements, and only the head of the list is referenced, which statement below best describes how many steps it will take to insert another element at the back of the list?
N/2 steps
One step
N*2 steps
N steps
What is output by the code shown below, where length represents the number of elements?
(a)
Which choices are true about one dimensional arrays? Check all that apply.
An array can contain elements of different data types at the same time.
Values are stored in contiguous memory.
Values are accessed using an indexing process.
Once an array has been created, it is static, and cannot grow or shrink in size.
After the integer elements 5, 3, 7, 1, 2, 4 are correctly inserted into an ascending order binary search tree, what is the resulting in-order traversal? Fill in the blank with the correct sequence of digits with no spaces between.
(a)
What is output by the following code sequence?
(a)
What is output by the following code sequence?
(a)
Which choice below is best described by the following statement?
Data structure that resembles a waiting line in a cafeteria, where elements join the list at the back, and are accessed or removed from the list at the front.
Tree
Graph
Stack
Array
Queue
After the integer elements 5, 3, 7, 1, 2, 4 are correctly inserted into a minimum heap tree, with the value 5 as the initial root, and the value 6 added to the heap, which term or terms below best describes the resulting tree? Check all that apply.
Full tree
Balanced tree
Complete tree
Which choice below is best described by the following statement?
Data structure containing several nodes, often called vertices, which are connected to other nodes using edges, which can be directed or undirected.
Linked List
Queue
Array
Stack
Graph
What is output by the code shown?
5
6
12
2
Using the class definition and diagram shown, with the linked list at the top of the diagram referenced by Node p, match the statements provided in the correct sequence to correctly construct and insert the new node into the list, resulting in the list shown in the lower portion of the diagram.
Node t = new Node()
Line 1
t.data = 7
Line 2
Node temp = p.next.next
Line 3
p.next.next = t
Line 4
t.next = temp
Line 5
Which choice is NOT true about two dimensional arrays
Values are accessed using an indexing process, where the first index represents the column, and the second represents the row.
The number of columns in each row can be different.
Values are stored in contiguous memory.
All elements contained in the array must be of the same data type.
A special kind of queue is required where elements are inserted in natural ascending order, often called a priority queue. The element popped from the front of this queue is always the smallest item in the list. Which of the following data structures will best implement this requirement?
Minimum Heap
Array
Linked List
Binary Search Tree
What is output by the code shown?
(a)
Which choice below is best described by the following statement?
Data structure containing several nodes, each of which can point to two other nodes, often referred to as children.
Stack
Queue
Tree
Array
Linked List
Which choice below is best described by the following statement?
Data structure where insertion or deletion of elements is restricted to only one end of the list.
Array
Graph
Stack
Queue
Linked List
A linear data structure required is to be flexible in size, where elements can be added and accessed anywhere in the list. Which of the following data structures meets these requirements?
Linked List
Array
Tree
Graph
Stack
Referring to graph illustration, which choices represent possible paths within the graph? Check all valid paths.
BEABDC
CBAEAC
EADCBD
ABEDBA
DABEDC
Using the class definition, diagram and partial code shown, which code segment will correctly replace <code> resulting in temp referencing the final node of the list? Check all that apply.
temp.next != null
temp.next == null
temp != 5
temp.data != 4
temp != null
What is the resulting array after the code segment shown below is executed? Write the answer in the blank in the exact format as shown in the bolded portion below, beginning with an open brace, listing elements separated by commas, no spaces between, ending with a closing brace.
(a)
Using the tree node class definition below, partial client code is shown for a inserting characters of the string "PETUNIA" into a binary search tree, resulting in the tree displayed. Which choice best replaces <code> to correctly insert the next node into the tree?
root.right.left = temp
root.left.left = temp
root.left.right = temp
root.right.right = temp
Which of these terms refer to the general process of repeating code elements inside a program? Check all that apply.
looping
recursion
sequence
iteration
branching
In the code segment shown, match each line with the term that best describes the code on that line.
Start
Line 1
Step
Line 2
Check
Line 3
Action
Line 4
How many times can the start of a loop happen?
More than four times
Twice
Four times
Three times
Once
During the execution of the code segment shown, how many times does the "check" portion of the loop occur?
(a)
For the code segment shown, what is the last value printed?
(a)
List the values of the line numbers according to the sequence of the statements in the code segment below. List all digits in a row with no spaces between.
The answer will be begin with the digits 123 and end with 5.
(a)
Which <start>, <check> and <step> options in the choices below will cause the action of this loop to occur 10 times?
int x ← 1 ; x < 10; x++
int x ← 5 ; x < 33; x+= 3
int x ← 0 ; x ≤ 10; ++x
int x ← 1 ; x ≤ 10 ; x++
int x ← 0 ; x < 10; ++x
Which loop styles will ALWAYS act at least once?
do while
for
while
repeat until
How many stars will be output by this loop?
3
None
Infinitely many
5
4
What is output by this pseudocode segment?
(a)
What is output by this pseudocode segment?
(a)
Which control structure listed below is the primary one used in a recursive method?
if else statement
Loop
Sequential processing
Switch statement
Which of the terms listed represents the part of the recursive process that causes repetition?
Loop
Base case
if else statement
Recursive call
Which of the terms listed represents the part of the recursive method that stops the repetitive process?
Loop
Base case
Recursive call
if else statement
Which of the statements listed below are true regarding the use of loops and recursion? Check all that apply.
Both loops and recursion are processes used to repeat tasks in a program.
Loops are more memory efficient than recursive processes.
Use a loop when possible, and only use recursion when a loop is not possible, or is less effective.
There are some things a recursive process can do that a loop cannot or does with great difficulty.
What is output by this pseudocode segment?
(a)
What is output by this pseudocode segment?
(a)
Which choice shows an input value for num to produce the output shown below?
23
21
25
27
What statement best describes a value that could be input for x so the while loop shown below will never act?
Any value except 23
The value 23
Any value greater than 23
Any value less than 23
How many times will the action statement happen in the loop shown?
(a)
Select all choices listed below that are within the next five values in this base 8 sequence.
5, 6, 7
8
13
10
11
9
Match each identifier shown with the most appropriate type of identifier category.
variable
name
class
Person
constant
VALUE
method
doSomething()
Which choice best describes the stage in the software system life cycle which determines the structure of the software strategy and code?
Design
Maintenance
Implementation (Coding)
Testing
Analysis
Which of the choices listed represents the greatest value?
11000111 base 2
C3 base 16
304 base 8
196 base 10
Which design process below is most appropriate for a project where the design team has taken the analysis and identified many processes already defined that can be used to develop the project, saving much time and effort.
Stepwise refinement
Bottom up
Top down
Object Oriented
Which choice represents a development process combining features of other development models into a cyclical process, including several phases, one of which is risk analysis.
Waterfall
Spiral
Incremental
Agile
A certain method of class A works in a certain way, but how this is accomplished is not known. Which choice best describes this situation?
Polymorphism
Composition
Inheritance
Encapsulation
Abstraction
The definition of an object in OOP, describing the type of data owned by the object, as well as methods that act on that data.
object
class
method
procedure
function
An aspect of object oriented programming incorporating related data items and methods into a class definition, including instance variables, constructors, accessor and modifer methods is often referred to as:
Abstraction
Polymorphism
Composition
Inheritance
Encapsulation
Classify each piece of data according to the choices given.
char
'e'
double
4.87
String
"Joe"
boolean
True
int
42
What is the next value in this binary sequence?
101, 110, 111
(a)
Identify the data type for this value:
"G"
String
boolean
int
char
float
Which choice best describes the feature of OOP that allows for classes to be defined based on previously defined and developed classes, receiving all of the characteristics of the original class, and then expanding on those features, easily identified as an "is a" relationship.
Polymorphism
Encapsulation
Inheritance
Abstraction
Composition
Select the best choice describing a structured comment block indicating the expected output for a process.
Postcondition
External documentation
Block comment
Precondition
Single line comment
Choose the statement that best classifies the identifier creation guideline shown.
Contains only alphanumeric characters, or the underscore character
Good idea
Rule
Convention
If the character 'e' has an ASCII value of 101, what would be the sum of all the ASCII characters in the word "face"?
(a)
Polymorphsim means "many forms", a key element of object oriented programming, with three main characteristics. Match each description below to the appropriate characteristic.
Polymorphic reference
The instance of a parent class can point to any instances of its child classes
Overloading
A class defines several constructors for an object, each with a unique parameter signature
Overriding
An inherited method is redefined by the child class
Which choice best describes the situation when a method of class F inherited from class G is redefined in a more special way?
Polymorphism - polymorphic object
Polymorphism - overloading
Inheritance
Polymorphism - overriding
Composition
A programming language using words and commands easy for humans to understand and organize, but which must be translated into a language easy for the computer to understand and execute.
Compiled
High Level
Low Level
Interpreted
Which choice best describes the type of programming language directly understood and executed by a computer, consisting of pure 0s and 1s?
Assembly Language
Architecture
Machine Language
Pseudocode
Choose the statement best classifying the following identifier example:
me_You
Invalid - contains invalid symbols
Invalid - does not start with a letter or underscore
Valid
Invalid identifier - Java reserved word
Invalid identifier - contains spaces
The fundamental type of data in a computer, the binary digit, or bit, is represented in different ways. Of the choices shown, check each one that is typically used to represent a bit.
1, 0
true, false
on, off
high voltage, low voltage
warm, cold
Choose the statement below that best classifies the following identifier example.
return
Valid
Invalid identifier - contains spaces
Invalid - does not start with a letter or underscore
Invalid identifier - Java reserved word
Invalid - contains invalid symbols
A customer from a startup company approaches a software development company with a software project to serve one of their company needs. A meeting is scheduled to begin the process of determining all aspects of the project during which representatives of the software company ask questions of the customer to ascertain the specific details of the requirements. Which choice represents this part of the software system life cycle?
Implementation
Design
Maintenance
Testing
Analysis
A "readme.txt" file is created to serve as instructions for a software project delivered to a customer. Which choice best describes this feature?
Internal documentation
Block comments
Precondition
Postcondition
External documentation
Which choice represents a program feature that activates a predefined block of code?
Return method or function
Method call
Void method or procedure
Procedure
When a program executes just fine, but the outcome is incorrect, this is a classified as a ______________ error.
Lexical
Syntax
Logic
Runtime
Which of the following are considered good program debugging strategies? Check all that apply.
Look at the arrows in the compiler generated error messages to locate the error.
Hide portions of the program that don't seem to work and "unhide" them one at a time until the offending line is discovered.
Intentionally use bad data to see if your program can handle it.
Read the error messages provided by the compiler.
Which choice describes a programming block of code that produces a calculated value?
Void method or procedure
Return method or function
Method call
Procedure
What output is produced by this block of code when 'b' is input?
catpighorse
catpighorsecow
cat
catpig
In this pseudocode example, String name is an example of a(an) __________ parameter.
Value
Actual
Formal
Reference
Not capitalizing a reserved word that should be capitalized in a programming statement is a ______________ error.
Runtime
Syntax
Lexical
Logic
Which choices represent the possible operators correctly filling the blank resulting in an output value of 14? Check all that apply.
≠
≥
>
<
≤
What is output by the pseudocode segment shown?
25
10
15
5
Select all combinations that make this expression TRUE.
boolean p ← false, boolean q ← false
boolean p ← true, boolean q ← false
boolean p ← false, boolean q ← true
boolean p ← true, boolean q ← true
Forgetting to end a string with a double quote symbol is a ______________ error.
Logic
Lexical
Syntax
Runtime
The code segment below calculates a week's pay based on number of years experience. For 1 year of experience, the hourly wage is $7, for 2 years $8 an hour, 3 years $10, 4 years $12, and 5 years $15 per hour. The number of hours will vary between 1 and 40 hours. What input value for years will result in a totalWeekPay output value of $480?
(a)
Select the choice that represents the final value of z after the code segment is executed.
True
False
What is output by the pseudocode segment shown?
True
False
During the execution of a program, entering a String when an integer is expected is an example of a ______________ error.
Syntax
Logic
Runtime
Lexical
What is output by the pseudocode segment shown?
True
False
What is the complete output of this pseudocode segment? The answer contains exactly 8 single digits with no spaces between.
(a)
A switch statement is useful when your program logic contains a chain of ______.
loops
if else statements
parameters
method calls
variable declarations
The type of parameter where changes by the method DO affect the original data.
Actual parameter
Reference parameter
Value parameter
Formal parameter
What is output by the pseudocode segment shown?
(a)
Select the choice representing the final value of this Boolean expression.
True
False
Match each line in the code segment below with the phrase that best describes the program statement on each line.
Return Method Header
Line 1
Return Statement
Line 2
Assignment Statement
Line 6
Method Call
Line 7
What is output by this code segment?
(a)
Which choice shows the correct parameter signature for the doStuff method header based on the final output shown below?
passed_by_reference int x, passed_by_reference y
passed_by_value int x, passed_by_reference y
passed_by_reference int x, passed_by_value y
passed_by_value int x, passed_by_value y
Match each set of input values to the correct program result.
line is ascending left to right
1234
line is descending left to right
1432
line is horizontal
1232
No output due to runtime error
1213
