wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS 241 Practice Test Full Length

Total questions: 109

Worksheet time: 9hrs 5mins

Name
Class
Date
1.

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.

a)

Full tree

b)

Complete tree

c)

Balance tree

2.

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?

a)

Merge Sort

b)

Bubble Sort

c)

Selection Sort

d)

Quick Sort

e)

Insertion Sort

3.

Data structure contained in static, contiguous memory, where all items can be easily assigned and accessed using an indexing process.

a)

Linked List

b)

Tree

c)

Array

d)

Queue

e)

Stack

4.

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.

a)

Linked List

b)

Tree

c)

Array

d)

Queue

e)

Stack

5.

Data structure where access to elements is restricted, only adding to the back and retrieving from the front.

a)

Linked List

b)

Tree

c)

Array

d)

Queue

e)

Stack

6.

Data structure where access to elements is restricted, only adding to or retrieving from the top.

a)

Linked List

b)

Tree

c)

Array

d)

Queue

e)

Stack

7.

Data structure consisting of nodes with a parent/child relationship.

a)

Linked List

b)

Tree

c)

Array

d)

Queue

e)

Stack

8.

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.

a)
b)
c)
9.

Choose the statement below that best classifies the following identifier example.


me_and_you

a)

Invalid identifier - reserved word

b)

Invalid - does not start with a letter or underscore

c)

Valid

d)

Invalid - contains invalid symbols

e)

Invalid identifier - contains spaces

10.

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)

a)

true

false

b)

false

false

c)

true

true

d)

false

true

11.

Using the class definition and client code shown below, which of the choices shown below are valid client code statements for line 20?

a)

s.age = s.age + 1

b)

print s.getAge()

c)

s.setAge(24)

d)

print s.age

12.

For which sort's implementation is this code most likely used?

a)

Insertion sort

b)

Merge sort

c)

Selection sort

d)

Quick sort

13.

What is output by the following code sequence?

a)

22

b)

16

c)

24

d)

14

14.

Which of the choices shown could be the action part of a loop? Check all that apply.

a)

Input

b)

Calculation

c)

Output

d)

Another loop

e)

Conditional Statement

15.

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?

a)

Inheritance

b)

Polymorphism

c)

Composition

d)

Encapsulation

e)

Abstraction

16.

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?

a)

Binary Search Tree

b)

Linked List

c)

Array

d)

Maximum Heap

e)

Minimum Heap

17.

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?

a)

Procedure (void method)

b)

Defintion

c)

Header

d)

Function (return method)

e)

Call

18.

How many times will the action statement happen in the loop shown?


int x ← 0

while(x ≤ 23)

<action>

x ← x + 1

end while

a)

24

b)

23

c)

22

d)

21

19.

Which of the following are considered good program debugging strategies? Check all that apply.

a)

Read the error messages provided by the compiler

b)

Intentionally use bad data to see if your program can handle it

c)

Delete the entire program and start all over again.

d)

Look at the arrows in the error messages to locate the error

20.

Which of the following is considered to be BOTH a valid input and output device?

a)

Keyboard

b)

Mouse

c)

Printer

d)

Flash Drive

21.

A switch statement is useful when your program logic contains a chain of ______.

a)

variable declarations

b)

method calls

c)

parameters

d)

if else statements

e)

loops

22.

During the execution of a program, entering a String when an integer is expected is a ______________ error.

a)

runtime

b)

logic

c)

syntax

d)

lexical

23.

Program language that is Directly understood and executed by a computer, consisting of pure 0s and 1s.

a)

Java

b)

Assembly

c)

C++

d)

Machine

e)

Fortran

24.

Program language that Uses abbreviation commands like MOV, STR, and JMP to work directly with the CPU

a)

Java

b)

Assembly

c)

C++

d)

Machine

e)

Fortran

25.

Program language that's For engineering and math applications

a)

Java

b)

Assembly

c)

C++

d)

Machine

e)

Fortran

26.

Program language that's For business applications.

a)

Java

b)

Assembly

c)

C++

d)

COBOL

e)

Fortran

27.

Program language that's For general purpose applications, able to directly access system resources

a)

Java

b)

Assembly

c)

C++

d)

COBOL

e)

Fortran

28.

Program language that's Object Oriented, developed applications able to run on any platform

a)

Java

b)

Assembly

c)

C++

d)

COBOL

e)

Fortran

29.

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)  

30.

What is output by the code shown below? Enter a numeric answer, or the letter E if an error occurs.

(a)  

31.

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.

a)

for loop

b)

do while loop

c)

repeat until loop

d)

while loop

32.

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")

a)

void sayHello(String name) -> method header

b)

sayHello("Suzy") -> method call

c)

(String name) -> formal parameter

d)

(Suzy") -> actual parameter

e)

sayHello -> function

33.

When a program executes without failure, but the result or outcome is incorrect, this is called a ______________ error.

a)

Runtime

b)

Lexical

c)

Logic

d)

Syntax

34.

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

a)

= =

b)

\le

c)

\ge

d)

<<

e)

>>

35.

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

a)

1, 3, 4, 3

b)

1, 2, 4, 3

c)

1, 3, 3, 2

d)

1, 2, 3, 4

36.

What is output by this code segment?

a)

0

b)

1

c)

2

d)

-1

37.

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

a)

1.internal 2.internal 3.external 4.style 5.internal 6.style 7.external 8.style

b)

1.internal 2.internal 3.internal 4.style 5.internal 6.style 7.external 8.style

c)

1.style 2.internal 3.external 4.style 5.external 6.style 7.external 8.style

d)

1.style 2.internal 3.internal 4.style 5.external 6.style 7.external 8.style

38.

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?

a)

5 3 1 2 7 4

b)

1 2 5 3 4 7

c)

5 3 1 2 4 7

d)

1 2 3 4 5 7

39.

What is the complete output of the pseudocode example shown here?

a)

2-2:2:7:5:7-

b)

2-2:2:7:10:2-

c)

2-2:2:7:10:10-

d)

2-2:2:10:10:10-

40.

Which choice below indicates a design process that takes previously developed and tested modules to build a larger software project?

a)

Bottom up

b)

UML

c)

Flowchart

d)

Top Down

41.

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)

a)

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

b)

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

c)

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

42.

What is output by this code segment?

a)

-186

b)

-84

c)

-774

d)

No output

e)

-90

43.

Which choice represents the original order of data resulting in the creation of the binary search tree shown?

a)

4 5 1 3 2 7 6

b)

4 2 7 6 5 1 3

c)

4 2 3 1 5 6 7

d)

4 5 2 3 1 7 6

44.

Which term below describes the type of software characterized by word processors, spreadsheets, data bases, and presentation programs?

a)

System

b)

Browser

c)

Application

d)

Protection

45.

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?

a)

Zombie

b)

Virus

c)

Worm

d)

Trojan

46.

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

a)

1.start 2.check 3.action 4.step

b)

1.start 2.step 3.action 4.check

c)

1.start 2.action 3.step 4.check

d)

1.start 2.check 3.step 4.action

47.

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?

a)

1 2 3 4 5 7

b)

5 7 3 4 2 1

c)

2 1 4 3 7 5

d)

5 3 1 2 4 7

48.

How many stars will be output by this loop?

a)

5

b)

4

c)

3

d)

none

e)

infinitely many

49.

Not capitalizing a reserved word that should be capitalized in a programming statement is an example of a ______________ error.

a)

Lexical

b)

Syntax

c)

Runtime

d)

Logic

50.

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

a)

1

17

b)

17

1

c)

2

1

d)

1

2

51.

Match each internet related protocol with the correct description.


1.TCP/IP 2.SMTP 3.POP 4.HTTP

a)

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

b)

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

c)

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

d)

1.Protocol on which the entire internet runs on 2.Protocol controls email storage 3.Protocol controls email delivery4.Protocol controls web page retrieval

52.

Which of the choices below indicates system programs permanently "burned" into ROM chips containing basic startup routines for a computer?

a)

firmware

b)

cloud

c)

software

d)

hardware

53.

A method of class F, inherited from class G, is redefined in a more special way. Which term represents this situation?

a)

Abstraction

b)

Polymorphism - overriding

c)

Inheritance

d)

Polymorphism - overloading

e)

Polymorphism - polymorphic object

54.

Fill in the blank with the correct value of N to cause the action of this loop to occur exactly 15 times.

a)

16

b)

15

c)

14

d)

13

55.

Choose the statement below that correctly classifies the following identifier example. Check all that apply.


@first_name

a)

Invalid - does not start with a letter or underscore

b)

Invalid identifier - contains spaces

c)

Invalid - contains invalid symbols

d)

Valid

e)

Invalid identifier - reserved word

56.

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?

a)

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.

b)

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.

c)

Serif fonts are usually easier to read in printed works than sans-serif fonts, since they help the brain more easily recognize the letter.

d)

All of these statements represent valid opinions of the day regarding serif vs sans serif fonts.

57.

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?

a)

The if statement detects a section of the list that is too small to partition any further and ends execution

b)

The if statement detects new bounds of a partition and returns it

c)

The if statement detects that the entire list has been sorted and ends execution

d)

The if statement detects a pivot value and returns it

58.

Which choice below indicates a key element of object oriented programming where inherited methods can be overloaded or overridden as needed and desired?

a)

Composition

b)

Polymorphism

c)

Inheritance

d)

Encapsulation

e)

Abstraction

59.

Which of the statements below are considered an appropriate part of the collaborative group learning process? Check all that apply.

a)

Be open to others' ideas, listen to all viewpoints, and be willing to compromise in order to reach a joint consensus.

b)

Measure the success of the project only after it has been completed.

c)

Have the students take on specific tasks within the group, all contributing differently, but with relatively equal efforts.

d)

Have the group help decide what the goal for the project should be.

60.

Which of the terms listed represents the part of the recursive method that stops the repetitive process?

a)

Base case

b)

Recursive call

c)

Loop

d)

If else statement

61.

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?

a)

5

b)

4

c)

3

d)

2

e)

1

62.

Which of the terms listed represents the part of the recursive method that causes repetition?

a)

Recursive call

b)

If else statement

c)

Loop

d)

Base Case

63.

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.

a)

Linked List

b)

Array

c)

Graph

d)

Tree

e)

Queue

64.

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?

a)

=C2*$E$2

b)

=C2*E2

c)

=C2*.25

d)

=C2*E$2

65.

Which choice is NOT true about one dimensional arrays?

a)

Once an array has been created, it is static, and cannot grow or shrink in size.

b)

Values are accessed using an indexing process.

c)

An array can contain elements of different data types at the same time.

d)

Values are stored in contiguous memory.

66.

What is output by the pseudocode segment shown?


int x ← 6

int y ← 10

print x == y

a)

true

b)

false

67.

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?

a)

Inheritance

b)

Polymorphism

c)

Composition

d)

Encapsulation

e)

Abstraction

68.

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.?

a)

DOS

b)

Bit

c)

AI

d)

Byte

69.

What value could be input for num in order to produce the output shown below?

a)

25

b)

23

c)

21

d)

27

70.

What is output by this pseudocode segment?

a)

8

b)

7

c)

6

d)

5

e)

4

71.

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?

a)

N/2 steps

b)

One step

c)

N*2 Steps

d)

N Steps

72.

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.

a)

Graph

b)

Stack

c)

Tree

d)

Queue

e)

Linked List

73.

Which of the choices below indicates a connector that has 15 pins and is used to connect a computer to a monitor?

a)

USB

b)

HDMI

c)

VGA

d)

Serial

74.

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?

a)

Polymorphism

b)

Encapsulation

c)

Inheritance

d)

Composition

e)

Abstraction

75.

What is output by the code shown below?

a)

12

b)

5

c)

6

d)

2

76.

Which of the following uses of school email is NOT appropriate according to a typical "acceptable use policy" for a school district?

a)

An administrator sending a message congratulating a teacher for an excellent lesson presented during an observation.

b)

Sending a help message to the technology department to assist with a broken school printer.

c)

Sending a group message to a department announcing an important curriculum meeting.

d)

Sending a broadcast message to all staff members advertising the sale of a personal item.

77.

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.

a)

View a video of folk dancers simulating the sort

b)

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

c)

Work through the pseudocode for the sort

d)

Use playing cards to simulate the sorting process

78.

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?

a)

Spiral

b)

Agile

c)

Waterfall

d)

Incremental

79.

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?

a)

Database file

b)

Slide Show Presentation

c)

Spreadsheet document

d)

Word processing document

80.

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)

A switch preserves bandwidth, where a hub dilutes bandwidth.

b)

A switch uses less electrical energy than a hub.

c)

A switch can handle more connections than a hub.

d)

All of these reasons are valid.

81.

What is output by the code shown below, where length represents the number of elements (rows in the array, or columns in a row)?

a)

20

b)

16

c)

6

d)

12

82.

Identify the data type for this value:

'G'

a)

boolean

b)

char

c)

string

d)

int

e)

float

83.

Which statement listed below best describes a value that could be input for x so that the while loop shown below will never act?

a)

The value 23

b)

Any value less than 23

c)

Any value greater than 23

d)

There is no value that will prevent this loop from executing

e)

Any value except 23

84.

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?

a)

TIFF

b)

BMP

c)

PNG

d)

JPEG

85.

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?

a)

Word processing document

b)

Database file

c)

Spreadsheet document

d)

Slide show presentation

86.

Which <start>, <step> and <check> options in the choices below will cause the action of this loop to occur 10 times?

a)

int x ← 0 ; x ← x + 1 ; x < 10

b)

Only two of these

c)

int x ← 1 ; x ← x + 1 ; x ≤ 10

d)

int x ← 5 ; x ← x + 3 ; x < 33

e)

All of these

87.

Choose the statement that best classifies the identifier creation guideline shown.


Contains only alphanumeric characters, or the underscore character

a)

rule

b)

convention

c)

good idea

88.

Which of the statements listed below is NOT true regarding the use of loops and recursion?

a)

All of these statements are true.

b)

There are some things a recursive process can do that a loop cannot.

c)

When possible, use a loop, and only use recursion when a loop is not possible, or is less effective.

d)

Loops are more memory efficient than recursive processes.

e)

Both loops and recursion are processes used to repeat tasks in a program

89.

Which choice listed below indicates the stage in the software system life cycle that involves writing the code using a programming language?

a)

Analysis

b)

Maintenance

c)

Design

d)

Implementation

e)

Testing

90.

Which of the following search phrases will find any instances of text, in any order, that contain both the words, peanuts and coke?

a)

peanuts and coke

b)

"peanuts and coke"

c)

peanuts not coke

d)

peanuts or coke

91.

Identify the data type for this value:

100

a)

String

b)

Float

c)

Int

d)

Boolean

e)

Char

92.

What is output by the pseudocode segment shown?


int x ← 9

int y ← 11

print x ≤ y

a)

true

b)

false

93.

What is output by the pseudocode segment shown?


int x ← 5

int y ← 10

int z ← -3

print x <= y AND x >= z

a)

true and true

b)

false

c)

true and false

d)

true

94.

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?

a)

The proper driver software has not been installed on the computer.

b)

The new printer was not correctly selected when the print request was made

c)

The printer's IP address has not been properly configured.

d)

There is no paper in the printer

95.

Which control structure listed below is the primary one used in a recursive method?

a)

All of these

b)

Switch statement

c)

Sequential processing

d)

if else statement

e)

Loop

96.

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()

a)

14

b)

16

c)

24

d)

22

97.

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?

a)

{ 0, 1, 2, 3, 5, 6, 4, 7 }

b)

{ 0, 1, 2, 3, 5, 4, 6, 7 }

c)

{ 0, 1, 2, 3, 4, 5, 7, 6 }

d)

{ 0, 1, 2, 3, 5, 7, 4, 6 }

98.

In the switch statement shown below, what is the output when the letter 'b' is input?

a)

nothing

b)

dog

c)

cat

d)

catpig

99.

Which choice below best describes the situation where the running time of a binary search is O(1)?

a)

When the target value being searched is found at the end of the list.

b)

When the target value being searched is found at the beginning of the list.

c)

When the target value being searched is not found.

d)

When the target value being searched is found in the middle of the list.

100.

Which of these would be considered the worst case scenario for a linear search?

a)

The target value is found somewhere in the middle of the list.

b)

The target value is found at the beginning of the list.

c)

The target value is not found in the list.

d)

The target value is found at the end of the list.

101.

Which of the following best describes a selection sort?

a)

The next "best" value is swapped into its correct position with each pass.

b)

Values that are out of place are shifted into order.

c)

Adjacent values are compared and swapped if out of order.

d)

The list is partitioned around a pivot point.

102.

Which of the following descriptions of the Big O analysis categories is NOT correct?

a)

An O(N) process is characterized by a loop that spans the entire data set of size N.

b)

An O(N^2) process is characterized by a nested loop process based on the size of the data set.

c)

An O(N log N) process is characterized by a divide and conquer process combined with an N based loop.

d)

An O(1) process only works on a data set of 100 items or less.

103.

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?

a)

1

b)

4

c)

5

d)

6

104.

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?

a)

insertion

b)

bubble

c)

merge

d)

quick

e)

selection

105.

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?

a)

10

b)

9

c)

-1

d)

13

106.

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?

a)

3

b)

1

c)

4

d)

2

107.

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?

a)

{ 1, 2, 7, 4, 3, 9, 6, 5, 8 }

b)

{ 1, 2, 3, 4, 7, 9, 6, 5, 8 }

c)

{ 1, 6, 4, 3, 7, 2, 5, 8, 9 }

d)

{ 1, 6, 7, 4, 3, 9, 2, 5, 8 }

108.

Consider the following array:

{ 0, 1, 6, 4, 2}


In how many passes will an ascending order bubble sort process be completed?

a)

2

b)

4

c)

5

d)

3

109.

Which of the statements below is NOT correct regarding the class definition shown here?

a)

The methods defined in lines 13 through 16 are accessor methods

b)

The method defined in lines 7 and 8 controls the construction of a StudentInfo object

c)

Lines 2 and 3 contain private instance field declarations

d)

The methods defined in lines 9 through 12 are mutator methods

e)

More than one of the above statements is incorrect.