Font size
WorksheetsCS 241 Practice Test Full Length
Total questions: 109
Worksheet time: 9hrs 5mins
After the integer elements 5, 3, 7, 1, 2, 4, and 8 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
Complete tree
Balance tree
If a new value is added to the front of a sorted list, which of these sorting routines is best to use to re-sort the list containing the new value?
Merge Sort
Bubble Sort
Selection Sort
Quick Sort
Insertion Sort
Data structure contained in static, contiguous memory, where all items can be easily assigned and accessed using an indexing process.
Linked List
Tree
Array
Queue
Stack
Data structure consisting of nodes in random memory connected in a single chain, making it able to grow or shrink, but a bit more tedious to manage.
Linked List
Tree
Array
Queue
Stack
Data structure where access to elements is restricted, only adding to the back and retrieving from the front.
Linked List
Tree
Array
Queue
Stack
Data structure where access to elements is restricted, only adding to or retrieving from the top.
Linked List
Tree
Array
Queue
Stack
Data structure consisting of nodes with a parent/child relationship.
Linked List
Tree
Array
Queue
Stack
Which of the tables below correctly match the given expression, where the first pair of digits in each row represent the true/false combination of p and q and the third digit represents the value of the expression, zero representing false and 1 representing true? Check all that apply.
Choose the statement below that best classifies the following identifier example.
me_and_you
Invalid identifier - reserved word
Invalid - does not start with a letter or underscore
Valid
Invalid - contains invalid symbols
Invalid identifier - contains spaces
Which combination below will correctly replace the question marks to cause the output of this expression to be false?
boolean p ← ??
boolean q ← ??
print (p AND q OR p XOR q)
true
false
false
false
true
true
false
true
Using the class definition and client code shown below, which of the choices shown below are valid client code statements for line 20?
s.age = s.age + 1
print s.getAge()
s.setAge(24)
print s.age
For which sort's implementation is this code most likely used?
Insertion sort
Merge sort
Selection sort
Quick sort
What is output by the following code sequence?
22
16
24
14
Which of the choices shown could be the action part of a loop? Check all that apply.
Input
Calculation
Output
Another loop
Conditional Statement
A certain method of class A works in a certain way, but how this is accomplished is not known. Which term listed below best indicates this concept?
Inheritance
Polymorphism
Composition
Encapsulation
Abstraction
A special kind of queue is required where elements are inserted in natural descending order, often called a priority queue. The element popped from the front of this queue is always the largest item in the list. Which of the following data structures will best implement this requirement?
Binary Search Tree
Linked List
Array
Maximum Heap
Minimum Heap
Which of the terms below indicates block of code in a program that just performs a task, like an internal calculation, input process, or output process?
Procedure (void method)
Defintion
Header
Function (return method)
Call
How many times will the action statement happen in the loop shown?
int x ← 0
while(x ≤ 23)
<action>
x ← x + 1
end while
24
23
22
21
Which of the following are considered good program debugging strategies? Check all that apply.
Read the error messages provided by the compiler
Intentionally use bad data to see if your program can handle it
Delete the entire program and start all over again.
Look at the arrows in the error messages to locate the error
Which of the following is considered to be BOTH a valid input and output device?
Keyboard
Mouse
Printer
Flash Drive
A switch statement is useful when your program logic contains a chain of ______.
variable declarations
method calls
parameters
if else statements
loops
During the execution of a program, entering a String when an integer is expected is a ______________ error.
runtime
logic
syntax
lexical
Program language that is Directly understood and executed by a computer, consisting of pure 0s and 1s.
Java
Assembly
C++
Machine
Fortran
Program language that Uses abbreviation commands like MOV, STR, and JMP to work directly with the CPU
Java
Assembly
C++
Machine
Fortran
Program language that's For engineering and math applications
Java
Assembly
C++
Machine
Fortran
Program language that's For business applications.
Java
Assembly
C++
COBOL
Fortran
Program language that's For general purpose applications, able to directly access system resources
Java
Assembly
C++
COBOL
Fortran
Program language that's Object Oriented, developed applications able to run on any platform
Java
Assembly
C++
COBOL
Fortran
What is output by this pseudocode segment?
int f(int x)
if(x ≥ 10)
return f(x - 4) - 2
else
return -4
end if else
end f
print f(18)
(a)
What is output by the code shown below? Enter a numeric answer, or the letter E if an error occurs.
(a)
A software input process is designed to validate correct input for a person's age. If the user accidentally enters their name instead, the input process detects the entry error and gently asks the user to try again, as many times as necessary, proceeding only when the input value is finally valid. Which of these programming techniques would best be used to implement this input validation process? Check all that apply.
for loop
do while loop
repeat until loop
while loop
In this pseudocode example, select all that match the code element with the correct designation.
void sayHello(String name)
print("Hello "+name+"!")
void main
sayHello("Suzy")
void sayHello(String name) -> method header
sayHello("Suzy") -> method call
(String name) -> formal parameter
(Suzy") -> actual parameter
sayHello -> function
When a program executes without failure, but the result or outcome is incorrect, this is called a ______________ error.
Runtime
Lexical
Logic
Syntax
Which symbols below will correctly fill the blank to output the value 14? Check all that apply.
int num1 ← 14
int num2 ← 35
if(num1 ____ num2)
print num2
else
print num1
= =
≤
≥
<
>
The adjacency matrix for a 5-node graph is shown below. For each pair of node values from the five nodes P, Q, R, S and T, with the first letter indicating the starting node and the second the ending node, enter a value indicating the shortest path length (fewest number of hops) it will take to travel along the graph from the starting node to the ending node. For example, the path designated by the letter pair PQ takes one hop, indicated by a 1 in the graph where row P row column Q. There are two paths for the letter pair TP, one of length 3 through nodes R and S, but a shorter of length 2, going through node R and then directly to P. Hint: draw the graph based on the matrix.
Find the path for SP, PR, PS, QP
1, 3, 4, 3
1, 2, 4, 3
1, 3, 3, 2
1, 2, 3, 4
What is output by this code segment?
0
1
2
-1
For each term listed, classify each as either internal documentation, external documentation, or a style convention.
1.Meaningful identifier, 2.Precondition statement, 3.readme.txt file, 4.Use of indenting 5.Postcondition statement 6.Use of Camel Case 7.Printed software manual
1.internal 2.internal 3.external 4.style 5.internal 6.style 7.external 8.style
1.internal 2.internal 3.internal 4.style 5.internal 6.style 7.external 8.style
1.style 2.internal 3.external 4.style 5.external 6.style 7.external 8.style
1.style 2.internal 3.internal 4.style 5.external 6.style 7.external 8.style
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, what is the preorder traversal of the tree?
5 3 1 2 7 4
1 2 5 3 4 7
5 3 1 2 4 7
1 2 3 4 5 7
What is the complete output of the pseudocode example shown here?
2-2:2:7:5:7-
2-2:2:7:10:2-
2-2:2:7:10:10-
2-2:2:10:10:10-
Which choice below indicates a design process that takes previously developed and tested modules to build a larger software project?
Bottom up
UML
Flowchart
Top Down
Consider a linked list represented by the class definition below, an example of a list shown by the diagram, with p referencing the first node in the list.
Several methods are defined and called to process the list, traversing and outputting all values in the list either in forwards order, reverse order, or something different. Classify each method call accordingly by selecting the corresponding choice that best describes the result of each method call
class Node
int data
Node next
end Node
//********************
void a (Node n)
if(n != null)
print n.data
a(n.next)
end if
end a
//********************
void b (Node n)
if(n != null)
b(n.next)
print n.data
end if
end b
//********************
void c (Node n)
while(n != null)
print n.data
n = n.next
end while
end c
//********************
void d (Node n)
while(n != null)
n = n.next
print n.data
end while
end c
//********* client code ***********
Node p = new Node()
//code to create the linked list shown in the diagram
1.a(p) 2.b(p) 3.c(p) 4.d(p)
1.List is output in forwards order 2.List is output in reverse order 3. List is output in forwards order 4.A different result occurs
1.List is output in reverse order 2.List is output in forwards order 3.List is output in reverse order 4.A different result occurs
1.List is output in forwards order 2.List is output in forwards order 3.different result occurs 4.List is output in forwards order
What is output by this code segment?
-186
-84
-774
No output
-90
Which choice represents the original order of data resulting in the creation of the binary search tree shown?
4 5 1 3 2 7 6
4 2 7 6 5 1 3
4 2 3 1 5 6 7
4 5 2 3 1 7 6
Which term below describes the type of software characterized by word processors, spreadsheets, data bases, and presentation programs?
System
Browser
Application
Protection
A computer has been infected with a harmful piece of software that tricked the user into loading and executing it on the system, but does not reproduce or self-replicate. Which term below best describes this software?
Zombie
Virus
Worm
Trojan
In a typical for loop, indicate the initial order of execution of the four parts of the loop by selecting the appropriate value for each part listed below.
Action Check Start Step
1.start 2.check 3.action 4.step
1.start 2.step 3.action 4.check
1.start 2.action 3.step 4.check
1.start 2.check 3.step 4.action
After the integer elements 5, 3, 7, 1, 2, 4 are correctly inserted into a binary search tree, which choice represents the post-order traversal of the nodes in the tree?
1 2 3 4 5 7
5 7 3 4 2 1
2 1 4 3 7 5
5 3 1 2 4 7
How many stars will be output by this loop?
5
4
3
none
infinitely many
Not capitalizing a reserved word that should be capitalized in a programming statement is an example of a ______________ error.
Lexical
Syntax
Runtime
Logic
What is output by the pseudocode segment shown?
int num1 ← 35, num2 ← 17
int num3 ← num1 % num2
int num4 ← num2 % num1
print num3
print num4
1
17
17
1
2
1
1
2
Match each internet related protocol with the correct description.
1.TCP/IP 2.SMTP 3.POP 4.HTTP
1.Protocol on which the entire internet runs on 2.Protocol controls email delivery 3.Protocol controls email storage 4.Protocol controls web page retrieval
1.Protocol controls web page retrieval 2.Protocol controls email delivery 3.Protocol controls email storage 4.Protocol on which the entire internet runs on
1.Protocol controls web page retrieval 2.Protocol controls email storage 3.Protocol controls email delivery 4.Protocol on which the entire internet runs on
1.Protocol on which the entire internet runs on 2.Protocol controls email storage 3.Protocol controls email delivery4.Protocol controls web page retrieval
Which of the choices below indicates system programs permanently "burned" into ROM chips containing basic startup routines for a computer?
firmware
cloud
software
hardware
A method of class F, inherited from class G, is redefined in a more special way. Which term represents this situation?
Abstraction
Polymorphism - overriding
Inheritance
Polymorphism - overloading
Polymorphism - polymorphic object
Fill in the blank with the correct value of N to cause the action of this loop to occur exactly 15 times.
16
15
14
13
Choose the statement below that correctly classifies the following identifier example. Check all that apply.
@first_name
Invalid - does not start with a letter or underscore
Invalid identifier - contains spaces
Invalid - contains invalid symbols
Valid
Invalid identifier - reserved word
There is an ongoing debate about which style of font is better to use, serif or sans serif. Which of the statements is considered to be true, according to current general opinions?
Sans serif fonts are considered better suited for online purposes due to the fact that monitors often have much poorer resolutions than printed works, making it more difficult to discern the small serifs.
The commonly used convention for printed work is to use a serif font for the body of the work. A sans-serif font is often used for headings, table text and captions.
Serif fonts are usually easier to read in printed works than sans-serif fonts, since they help the brain more easily recognize the letter.
All of these statements represent valid opinions of the day regarding serif vs sans serif fonts.
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 a section of the list that is too small to partition any further and ends execution
The if statement detects new bounds of a partition and returns it
The if statement detects that the entire list has been sorted and ends execution
The if statement detects a pivot value and returns it
Which choice below indicates a key element of object oriented programming where inherited methods can be overloaded or overridden as needed and desired?
Composition
Polymorphism
Inheritance
Encapsulation
Abstraction
Which of the statements below are considered an appropriate part of the collaborative group learning process? Check all that apply.
Be open to others' ideas, listen to all viewpoints, and be willing to compromise in order to reach a joint consensus.
Measure the success of the project only after it has been completed.
Have the students take on specific tasks within the group, all contributing differently, but with relatively equal efforts.
Have the group help decide what the goal for the project should be.
Which of the terms listed represents the part of the recursive method that stops the repetitive process?
Base case
Recursive call
Loop
If else statement
The switch statement below should calculate 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 $400?
5
4
3
2
1
Which of the terms listed represents the part of the recursive method that causes repetition?
Recursive call
If else statement
Loop
Base Case
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.
Linked List
Array
Graph
Tree
Queue
A formula has been entered into cell D2 that finds the percentage of the value in cell C2 (the product of cells A2 and B2) based on the factor in cell E2. This formula needs to be copied down to cells D3 through D6 to calculate the values shown based on the percentage values in column E. Which of the choices below works correctly to achieve the values shown?
=C2*$E$2
=C2*E2
=C2*.25
=C2*E$2
Which choice is NOT true about one dimensional arrays?
Once an array has been created, it is static, and cannot grow or shrink in size.
Values are accessed using an indexing process.
An array can contain elements of different data types at the same time.
Values are stored in contiguous memory.
What is output by the pseudocode segment shown?
int x ← 6
int y ← 10
print x == y
true
false
Which of the choices below indicates an aspect of object oriented programming that incorporates related data items and methods into a class definition, including instance variables, constructors, accessor and modifier methods?
Inheritance
Polymorphism
Composition
Encapsulation
Abstraction
Which choice shown below represents the fundamental type of data in a computer, often represented as zero and 1, false and true, off and on, etc.?
DOS
Bit
AI
Byte
What value could be input for num in order to produce the output shown below?
25
23
21
27
What is output by this pseudocode segment?
8
7
6
5
4
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
3_13
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.
Graph
Stack
Tree
Queue
Linked List
Which of the choices below indicates a connector that has 15 pins and is used to connect a computer to a monitor?
USB
HDMI
VGA
Serial
Which of the choices below indicates the feature of OOP that allows for classes to be defined based on previously defined and developed classes, using those classes as instance fields, indicating the "has a" relationship?
Polymorphism
Encapsulation
Inheritance
Composition
Abstraction
What is output by the code shown below?
12
5
6
2
Which of the following uses of school email is NOT appropriate according to a typical "acceptable use policy" for a school district?
An administrator sending a message congratulating a teacher for an excellent lesson presented during an observation.
Sending a help message to the technology department to assist with a broken school printer.
Sending a group message to a department announcing an important curriculum meeting.
Sending a broadcast message to all staff members advertising the sale of a personal item.
A computer science teacher is planning a unit on sorting routines and is considering several approaches, including the ones listed below. Which of the activities listed below would be the LEAST effective to use when first introducing the lesson for a particular sort.
View a video of folk dancers simulating the sort
Demonstrate the sort process on the board by tracing through the steps with a sample array of values, without any discussion of the code needed to implement the sor
Work through the pseudocode for the sort
Use playing cards to simulate the sorting process
Which of the choices below indicates the development process that combines features of other development models into a cyclical process, including several phases, one of which is risk analysis?
Spiral
Agile
Waterfall
Incremental
A teacher is needing to store data for a research project, with various sets of complex data related to student performances in a recent lesson unit, and wants to tie all the data together using student IDs as the key field. Which of these applications would be most effective for this purpose?
Database file
Slide Show Presentation
Spreadsheet document
Word processing document
Which choice below best describes the reason a switch is a better device than a hub to serve as the center of a star topology?
A switch preserves bandwidth, where a hub dilutes bandwidth.
A switch uses less electrical energy than a hub.
A switch can handle more connections than a hub.
All of these reasons are valid.
What is output by the code shown below, where length represents the number of elements (rows in the array, or columns in a row)?
20
16
6
12
Identify the data type for this value:
'G'
boolean
char
string
int
float
Which statement listed below best describes a value that could be input for x so that the while loop shown below will never act?
The value 23
Any value less than 23
Any value greater than 23
There is no value that will prevent this loop from executing
Any value except 23
Which of the following picture file formats is best-suited for use with web pages, and for storing images during the editing process because of its lossless compression?
TIFF
BMP
PNG
JPEG
A teacher is preparing an introductory computer science lesson to show basic information about data types, displaying the various types and what they contain. Which of the following applications would be most appropriate to produce accompanying printed notes for students?
Word processing document
Database file
Spreadsheet document
Slide show presentation
Which <start>, <step> and <check> options in the choices below will cause the action of this loop to occur 10 times?
int x ← 0 ; x ← x + 1 ; x < 10
Only two of these
int x ← 1 ; x ← x + 1 ; x ≤ 10
int x ← 5 ; x ← x + 3 ; x < 33
All of these
Choose the statement that best classifies the identifier creation guideline shown.
Contains only alphanumeric characters, or the underscore character
rule
convention
good idea
Which of the statements listed below is NOT true regarding the use of loops and recursion?
All of these statements are true.
There are some things a recursive process can do that a loop cannot.
When possible, use a loop, and only use recursion when a loop is not possible, or is less effective.
Loops are more memory efficient than recursive processes.
Both loops and recursion are processes used to repeat tasks in a program
Which choice listed below indicates the stage in the software system life cycle that involves writing the code using a programming language?
Analysis
Maintenance
Design
Implementation
Testing
Which of the following search phrases will find any instances of text, in any order, that contain both the words, peanuts and coke?
peanuts and coke
"peanuts and coke"
peanuts not coke
peanuts or coke
Identify the data type for this value:
100
String
Float
Int
Boolean
Char
What is output by the pseudocode segment shown?
int x ← 9
int y ← 11
print x ≤ y
true
false
What is output by the pseudocode segment shown?
int x ← 5
int y ← 10
int z ← -3
print x <= y AND x >= z
true and true
false
true and false
true
A new printer is being installed on a teacher's workstation, but isn't printing. The printer is plugged in, turned on, and connected properly to the computer, which is also on and functioning properly. Which of the following situations is NOT a likely cause of the problem?
The proper driver software has not been installed on the computer.
The new printer was not correctly selected when the print request was made
The printer's IP address has not been properly configured.
There is no paper in the printer
Which control structure listed below is the primary one used in a recursive method?
All of these
Switch statement
Sequential processing
if else statement
Loop
What is output by the following code sequence?Stack s ← new Stack()
s.push(7)
s.push(3)
s.push(s.peek()*2)
s.push(s.pop() + s.pop() + s.peek())
print s.pop()
14
16
24
22
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, 6, 4, 7 }
{ 0, 1, 2, 3, 5, 4, 6, 7 }
{ 0, 1, 2, 3, 4, 5, 7, 6 }
{ 0, 1, 2, 3, 5, 7, 4, 6 }
In the switch statement shown below, what is the output when the letter 'b' is input?
nothing
dog
cat
catpig
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 at the end of the list.
When the target value being searched is found at the beginning of the list.
When the target value being searched is not found.
When the target value being searched is found in the middle of the list.
Which of these would be considered the worst case scenario for a linear search?
The target value is found somewhere in the middle of the list.
The target value is found at the beginning of the list.
The target value is not found in the list.
The target value is found at the end of the list.
Which of the following best describes a selection sort?
The next "best" value is swapped into its correct position with each pass.
Values that are out of place are shifted into order.
Adjacent values are compared and swapped if out of order.
The list is partitioned around a pivot point.
Which of the following descriptions of the Big O analysis categories is NOT correct?
An O(N) process is characterized by a loop that spans the entire data set of size N.
An O(N^2) process is characterized by a nested loop process based on the size of the data set.
An O(N log N) process is characterized by a divide and conquer process combined with an N based loop.
An O(1) process only works on a data set of 100 items or less.
Consider a list:
{ 3, 5, 8, 10, 14, 34, 78, 123, 513, 999 }
If a binary search for the value 14 is performed, how many comparison operations will be required to find it?
1
4
5
6
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 below?
insertion
bubble
merge
quick
selection
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
-1
13
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?
3
1
4
2
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, 7, 4, 3, 9, 6, 5, 8 }
{ 1, 2, 3, 4, 7, 9, 6, 5, 8 }
{ 1, 6, 4, 3, 7, 2, 5, 8, 9 }
{ 1, 6, 7, 4, 3, 9, 2, 5, 8 }
Consider the following array:
{ 0, 1, 6, 4, 2}
In how many passes will an ascending order bubble sort process be completed?
2
4
5
3
Which of the statements below is NOT correct regarding the class definition shown here?
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
More than one of the above statements is incorrect.
