Test Bank Docx Chapter.8 Searching and Sorting Arrays - Practice Test Bank | Prelude Programming 6e Venit by Stewart Venit. DOCX document preview.

Test Bank Docx Chapter.8 Searching and Sorting Arrays

Test Bank for Prelude to Programming Chapter 8

MULTIPLE CHOICE

1. The following pseudocode searches for an item. Which variable represents a flag to indicate whether or not the item being searched for has been found? There are N elements in the array named A.

Input SearchItem

Set X = 0

Set Y = 0

While (Y == 0) AND (X < N – 1)

If A[X] == SearchItem Then

Set Y = 1

End If

Set X = X + 1

End While

a.

X

b.

Y

c.

A[X]

d.

N

2. If X = 6, Y = 9, and Z = 0, what values are in X, Y, and Z after code corresponding to the following pseudocode is executed?

Set Z = X

Set X = Y

Set Y = Z

a.

X = 9

Y = 6

Z = 0

b.

X = 0

Y = 6

Z = 9

c.

X = 9

Y = 6

Z = 9

d.

X = 9

Y = 6

Z = 6

3. A binary search begins by:

a.

comparing the search item to all the items in the list or array, on the first pass

b.

comparing the search item to half the items in the list or array on the first pass

c.

comparing the search item to the first item in the list or array on the first pass

d.

creating an index file

4. Which of the following is not one of the steps involved to carry out a selection sort which will sort an array in ascending order?

a.

on the first pass, the smallest element is located

b.

on the first pass, the smallest element is swapped with the first element in the array

c.

on the first pass, the smallest element is swapped with the last element in the array

d.

on the second pass, the second-smallest element is located

5. Which is the correct way to swap the value of elements K and J in an array named Price?

a.

Set Temp = Price[K]

Set Price[K] = Price[J]

Set Price[J] = Temp

b.

Set Temp = Price[K]

Set Price[J] = Temp

Set Price[K] = Price[J]

c.

Set Price[K] = Temp

Set Price[J] = Price[K]

Set Temp = Price[J]

d.

Set Price[K] = Temp

Set Temp = Price[J]

Set Price[J] = Price[K]

6. What is the function of a flag in the pseudocode for a binary search?

a.

it indicates when all the items in an array have been searched

b.

it acts as a counter

c.

it indicates that the item you are searching for has been found

d.

it is set to 0 to end the program

7. Assuming N, X, Y, and Z are previously been declared variables with Z as a String variable, which variable acts as a flag in the following pseudocode snippet:

Set X = 0

Set Y = 0

While (X == 0) AND (X < N)

If Z == “Joey”

Set Y = 1

End If

Set X = X + 1

End While

a.

N

b.

X

c.

Y

d.

Z

8. The following pseudocode is the general form for the ____________.

While (the array named Stuff is not sorted)

For (J = 0; J < N – 1; J++)

If Stuff[J] > Stuff[J + 1] Then

Interchange Stuff[J] and Stuff[J + 1]

End If

End For

End While

a.

Bubble sort

b.

Selection sort

c.

Serial search

d.

Binary search

9. The following pseudocode is the general form for the ____________.

For (J = 0; J < N; J++)

Find smallest (Small) of Stuff[J],Stuff[J+1]...,Stuff[N]

If Small != Stuff[J] Then

Swap elements Small and Stuff[J]

End If

End For

a.

Bubble sort

b.

Selection sort

c.

Serial search

d.

Binary search

10. The following are the basic steps for the ____________.

1. Load the table into parallel arrays, one for each column of the table.

2. Search the array of table keys by comparing the search key to the elements of this array, one by one, until a match occurs or the end of the array is reached.

3. Display the search key and corresponding table values or if the search key is not found in the array, display a message to this effect.

a.

Bubble sort

b.

Selection sort

c.

Serial search

d.

Binary search

11. The following pseudocode is the general form for the ____________.

Set Index = 0

Set Flag = 0

While (Flag == 0) AND (Index < N)

If SearchKey[Index] == Key Then

Set Flag = 1

End If

Set Index = Index + 1

End While

If Flag == 1 Then

Write SearchKey[Index – 1]

Else

Write “The item you are searching for was not found.”

End If

a.

Bubble sort

b.

Selection sort

c.

Serial search

d.

Binary search

12. In a computer program, a flag is normally …

a.

A Boolean variable

b.

A 1 or a 0

c.

Either true or false

d.

All of the above are true

TRUE/FALSE

1. True/False: The serial search cannot be used with a list of names.

2. True/False: The bubble sort can be used to sort strings.

3. True/False: In a serial search, a variable called a flag is often used to indicate whether or not the search has been successful. A flag takes on one of two values.

4. True/False: The bubble sort algorithm sorts data either ascending or descending.

5. True/False: In order to swap the values of two variables, it is necessary to use a third variable as a temporary holding location.

6. True/False: A binary search looks for a desired item by comparing the search item to each data item in order, from first to last, until a match is found.

7. True/False: The binary search requires that the array of data to be searched is in numerical or alphabetical order.

8. True/False: With the selection sort, to sort from smallest to largest, on the first pass, the smallest element is located and swapped with the first array element.

9. True/False: A flag is normally a Boolean variable.

10. True/False: The bubble sort technique is easy to use because it does not require the use of a swap routine.

11. True/False: Since there are already two search routines in use, it is never necessary to write your own code to search for an item.

12. True/False: The bubble sort routine and the selection sort routine are the only sort routines available to programmers.

SHORT ANSWER

1. The __________ __________ examines array elements, one by one, until the desired element is found.

2. The __________ __________ makes passes through an array, comparing consecutive pairs of elements and interchanging them if they are not in the correct order.

3. A variable that is used to indicate whether or not a specific action has taken place is called a(n) __________.

4. The item you are looking for when you perform a serial search is known as the __________ _________.

5. If a bubble sort arranges a list of names in alphabetical order, from A to Z, the sort is __________ (ascending/descending).

6. To sort an array of ten items with the bubble sort, it will take, at most, __________ passes to completely sort them.

7. A(n) __________ __________ requires that the table keys (the array of data to be searched) is in alphabetical or numerical order.

8. If an array contains N elements, using the selection sort, it will be sorted after, at most, __________ passes.

9. The __________ search method is a good way to search a large amount of data for a search key.

10. A(n) __________ __________ is used to exchange values of two elements.

11. In a binary search, the item you are looking for is called the search key or the __________.

12. When a search is done with parallel arrays, the __________ of elements in one array must always correspond with the __________ of elements in the other parallel arrays.

Document Information

Document Type:
DOCX
Chapter Number:
8
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 8 Searching and Sorting Arrays
Author:
Stewart Venit

Connected Book

Practice Test Bank | Prelude Programming 6e Venit

By Stewart Venit

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party