13

INT1111: Quiz 08 (Chapter 08)

INT1111: Quiz 08 (Chapter Eight) Name ------

Multiple Choice

1. Processing a large number of items in a(n) ______is usually easier than processing a large number of items stored in separate variables.

a. / Constant
b. / Variable
c. / Array
d. / Loop
e. / None of the above

2. What is the term used for the number inside the bracket that specifies the number of values that an array can hold?

a. / Size
b. / Size declarator
c. / Number
d. / Number declarator
e. / None of the above

3. Access the individual elements in an array by using their ______.

a. / Sizes
b. / Numbers
c. / Integers
d. / Subscripts
e. / None of the above

4. A partially filled array is normally used with ______.

a. / a library function that performs array insertions
b. / an accompanying variable that holds a copy of the last item stored in the array
c. / an accompanying integer variable that holds the number of items that are actually stored in the array
d. / a warning to the user that some of the elements contain invalid values
e. / None of the above

5. Some programming languages provide this specialized loop that steps through an array, retrieving the value of each element.

a. / While Each
b. / For Each
c. / Repeat Get
d. / Step Loop
e. / None of the above

6. Which is the simplest search technique to use to find an item in an array?

a. / Sequential
b. / Binary
c. / Bubble
d. / Select
e. / None of the above

7. Which of the following arguments must be passed when passing an array as an argument?

a. / The array itself
b. / An integer that specifies the number of elements in the array
c. / The data type of the array
d. / A and B
e. / A and C

8. ______arrays are two or more arrays that hold related data, and the elements are accessed using a common subscript.

a. / Sequential
b. / Binary
c. / Parallel
d. / Linear
e. / None of the above

9. How many subscripts do you need to access one element in a two-dimensional array?

a. / One
b. / Two
c. / Three
d. / Four
e. / None of the above

10. Two- dimensional arrays can be thought of as containing ______.

a. / Rows and columns
b. / Lines and pages
c. / Rows and pages
d. / Lines and columns
e. / Rows and pages

11. A three-dimensional array can be thought of as ______of two-dimensional arrays.

a. / Rows
b. / Columns
c. / Lines
d. / Pages
e. / None of the above

12. In the following declaration, what is the data type of the elements of the array?

Declare Integer numbers [SIZE]

a. / SIZE
b. / numbers
c. / Integer
d. / Declare
e. / None of the above

13. Every element in an array is assigned a unique number known as a ______.

a. / subscript
b. / integer
c. / character
d. / number
e. / None of the above

14. Which of the following statement is true about the statement below?

Declare Integer score [5] = 83, 92, 78, 94, 71

a. / This is an array declaration.
b. / This is an array initialization.
c. / This is an array size establishment.
d. / This is an array declaration and initialization.
e. / This is an array declaration and size establishment.

15. What is the subscript for the data value 92 in the example given below?

Declare Integer score [5] = 83, 92, 78, 94, 71

a. / One
b. / Two
c. / A
d. / B
e. / None of the above

16. What is the term used for the value that is searched for in a search algorithm?

a. / stringValue
b. / searchValue
c. / matchValue
d. / flag
e. / None of the above

17. The expression score[5] is pronounced ______.

a. / Score of 5
b. / Score 5
c. / Score sub 5
d. / Score of 4
e. / Score sub 4

True/False

18. True/False: Subscripts are used to identify specific elements in an array.

19 True/False: Unlike variables, arrays need to be initialized separately from the declaration.

20. True/False: Array bounds checking happens at runtime, which is while the program is running.

21. True/False: In a sequential search algorithm, the Boolean variable used as a flag is initialized to TRUE.

22. True/False: The first step in calculating the average of the values in an array is to get the total of the values.

23. True/False: If array name contains a list of names, name[1] is the name of the first person.

24. True/False: When processing the data in a two-dimensional array, each element has two subscripts.

25. True/False: Multiple-dimensional arrays can be used to model data that occurs in multiple sets.

Multiple Choice

1. Which sorting algorithm moves elements to their final sorted position in the array?

a. / Bubble
b. / Selection
c. / Insertion
d. / Hash
e. / None of the above

2. When the elements in an array are stored from lowest to highest, the array is sorted in ______order.

a. / Ascending
b. / Descending
c. / Numeric
d. / Alphabetic
e. / None of the above

3. As the ______sorting algorithm makes passes through and compares the elements of the array, certain values move toward the end of the array with each pass.

a. / Bubble
b. / Selection
c. / Insertion
d. / Hash
e. / None of the above

4. Which searching algorithm requires the array to be ordered?

a. / Sequential
b. / Binary
c. / Linear
d. / Parallel
e. / None of the above

5. Which sorting algorithm sorts the first two elements of an array before inserting the remaining elements into that sorted part of the array?

a. / Bubble
b. / Selection
c. / Insertion
d. / Hash
e. / None of the above

6. Which search algorithm uses three variables to mark positions within the array as it searches for the searchValue?

a. / Sequential
b. / Binary
c. / Parallel
d. / Linear
e. / None of the above

7. Which statement is true after the execution of the following statements?

Set x = y

Set y = x

a. / x and y contain their original values
b. / x and y swapped their values
c. / x contains the value in y and y stayed the same
d. / y contains the value in x and x stayed the same
e. / None of the above

8. In the bubble sort algorithm, the two arguments sent into the swap module are ______.

a. / array[index] and array[index-1]
b. / array[index+1] and array[index-1]
c. / array[index-1] and array[index+1]
d. / array[index-1] and array[index]
e. / None of the above

9. Which statement is true after the execution of the following statements?

Set t = x

Set x = y

Set y = t

a. / x and y contain their original values
b. / x and y swapped their values
c. / x contains the value in y and y stayed the same
d. / y contains the value in x and x stayed the same
e. / None of the above

10. In the swap module, the third variable is declared as a ______variable.

a. / Global
b. / Reference
c. / Local
d. / Constant
e. / None of the above

11. In an insertion sort, what order are the elements in an array placed using the following Boolean expression?

// variable p is used to scan the array

While p > 0 AND array[p-1] > array[p]

a. / Ascending
b. / Descending
c. / Numeric
d. / Alphabetic
e. / None of the above

12. What does the variable middle represent in a binary search algorithm?

a. / Subscript of the midpoint
b. / Middle value in the array
c. / Middle value in the portion to be searched
d. / The average of two values
e. / None of the above

13. In a binary search, what is the maximum number of comparisons that need to be performed if the array contained 1000 elements?

a. / 1000
b. / 500
c. / 250
d. / 100
e. / None of the above

14. In a selection sort, which variable holds the subscript of the element with the smallest value found in the scanned area of the array?

a. / minIndex
b. / minValue
c. / startScan
d. / SIZE
e. / None of the above

15. To order an array of strings in alphabetic order, the sorting algorithm should be structured for ______order.

a. / alphabetic
b. / numeric
c. / ascending
d. / descending
e. / None of the above

True/False

16 True/False: Swapping the contents of two variables requires a third variable that can serve as a temporary storage location.

17. True/False: The sequential search algorithm is simple and most efficient to use with a large data array.

18. True/False: Computer programming languages are only able to perform sort algorithms on numeric arrays.

19. True/False: The biggest advantage of the bubble sort algorithm is that values move only by one element at a time toward their final destination in the array.

20. True/False: In a binary search, if the search fails to find the item on the first attempt, then there are 999 elements left to search in an array of 1000 elements.

21. True/False: When values in an array need to be swapped, the array and the size of the array have to be sent to the swap module.

22. True/False: In a sequential search, each element is compared to the searchValue and the search stops when the value is found or the end of the array is encountered.

23. True/False: The swap module is executed with three arguments to correctly swap the elements in an array.

24. True/False: In a selection sort algorithm, the variable minValue holds the smallest value found in the scanned area of the array.

25. True/False: All sorting algorithms contain a group of statements that swap values in array elements.

1. A list of operations that is displayed on the screen is called a(n) ______.

a. / List
b. / Menu
c. / Option list
d. / Choice list
e. / None of the above

2. The acronym GUI stands for ______.

a. / Graphical user instrument
b. / Graphics uses interface
c. / Graphics uses instrument
d. / Graphical user interface
e. / None of the above

3. What is the structure that is needed to process a menu selection?

a. / Sequence
b. / Decision
c. / Iteration
d. / Loop
e. / None of the above

4. Which statement provides a Default section to validate the user’s menu selection?

a. / If-Then
b. / If-Then-Else
c. / If-Then-Else If
d. / Case
e. / None of the above

5. A(n) ______program always starts off by displaying a list of operations the user can select from.

a. / Menu-driven
b. / Interactive
c. / Graphical
d. / User-friendly
e. / None of the above

6. Which loop is a posttest loop such that the menu is displayed at least once?

a. / Do-While
b. / While
c. / For
d. / Any of the above
e. / None of the above

7. What type of menu first displays the main menu and then, based on the user’s selection, displays a submenu?

a. / Single-level menu
b. / Multiple-level menu
c. / Step-level menu
d. / Sub-level menu
e. / None of the above

8. Menu-driven programs should be broken down into ______that perform individual tasks.

a. / loops
b. / functions
c. / tasks
d. / modules
e. / None of the above

9. What is capable of performing several tasks and allows the user to select the task?

a. / Menu-driven programs
b. / Interactive programs
c. / Graphical programs
d. / User-friendly programs
e. / None of the above

10. What is the method used to make sure that valid selections are processed?

a. / Input validation loop
b. / Including the Default clause in the case structure
c. / Use of an Else clause
d. / All of the above
e. / None of the above

11. The items displayed in a menu are often preceded by a ______.

a. / Number
b. / Letter
c. / Other characters
d. / Any of the above
e. / None of the above

12. When the user makes a selection from the main menu in a multiple-level menu, a ______might be displayed next.

a. / Menu
b. / Main menu
c. / Grand menu
d. / Submenu
e. / None of the above

13. When the user is ready to stop the program, the user selects an operation such as “______” from the menu.

a. / STOP
b. / CTRL + Z
c. / CTRL + X
d. / CTRL + Q
e. / End of Program

14. Which symbol in flowcharting is appropriate to use to represent the display of each of the selections of the menu?

a. / Rectangle
b. / Parallelogram
c. / Diamond
d. / Terminal
e. / None of the above

15. Usually a submenu is executed by the selection made by the user from the ______.

a. / Module
b. / Case structure
c. / Display
d. / Main menu
e. / None of the above

True/False

16. True/False: An iteration structure is needed to process the menu selection made by the user.

17. True/False: The If-Then-Else If statement can be used as an alternative for performing the user’s menu selection.

18. True/False: The user’s menu selection can be validated using an input validation loop immediately after the Input statements.

19. True/False: It is not possible to give the user an opportunity to make additional selections from the menu without having to run the program.

20. True/False: When using a While loop to repeatedly process a user’s menu selections, the menuSelection variable need to be initialized.

21. True/False: It is ideal to have one long menu in the program for users to see and make their selection.

22. True/False: Modules cannot be executed from a case statement, so loops have to be used.

23. True/False: When there is an input validation loop, the case structure does not need the Default clause.

24. True/False: It is a cumbersome process for a user has to make selection from a menu because the user has to type the selection out.

25. True/False: In a menu-driven program the user would have to usually type the word ‘end’ to stop the program.