1 - Pearson



chapter 4

Arrays

True-False Questions

1. The upper bound is the highest index value in an array.

Answer: True Level: Easy

Section: 4-1 Page: 58

2. In a zero base array the upper bound is one less than the length of the array.

Answer: True Level: Moderate

Section: 4-1 Page: 58

3. The best way to store multiple items of related data is in a procedure.

Answer: False Level: Easy

Section: 4-1 Page: 58

4. Arrays are composed of multiple elements.

Answer: True Level: Easy

Section: 4-1 Page: 58

5. Indexes hold the data values of an array.

Answer: False Level: Easy

Section: 4-1 Page: 58

6. The first index of an array is typically has a value of 1.

Answer: False Level: Moderate

Section: 4-1 Page: 58

7. The default value of the elements in an array is set to 0.

Answer: True Level: Easy

Section: 4-1 Page: 58

8. Visual Logic uses the Make Array edit dialog box to declare an array.

Answer: True Level: Easy

Section: 4-1 Page: 59

9. The Create Array command opens the Create Array edit dialog box.

Answer: False Level: Moderate

Section: 4-1 Page: 59

10. An element in an array is identified by an index value in parentheses after the array name.

Answer: True Level: Easy

Section: 4-1 Page: 59

11. If no element is specified by an index value after the array name the first element of the array will be returned.

Answer: False Level: Hard

Section: 4-1 Page: 59

12. An out-of-bounds error is generated when the index value is larger than the upper bound.

Answer: True Level: Easy

Section: 4-1 Page: 59

13. The index of an array can be an integer constant or expression, but not a variable.

Answer: False Level: Easy

Section: 4-1 Page: 59

14. For Loops are used to cycle through every element in an array.

Answer: True Level: Easy

Section: 4-1 Page: 59

15. If you need to access data multiple times it is not good to use an array.

Answer: False Level: Easy

Section: 4-1 Page: 60

16. The Input dialog has an option to use a file to enter data.

Answer: True Level: Moderate

Section: 4-4 Page: 67

17. Two or more arrays are used to create parallel arrays.

Answer: True Level: Easy

Section: 4-6 Page: 70

18. A set of parallel arrays are associated together based on their index values.

Answer: True Level: Easy

Section: 4-6 Page: 70

19. The data type of the elements in parallel arrays must be of the same type (i.e. all strings).

Answer: False Level: Easy

Section: 4-6 Page: 70

20. A bubble sort uses three loops to re-arrange a list of numbers such that the largest values are at the bottom.

Answer: False Level: Moderate

Section: 4-6 Page: 72

Multiple Choice Questions

21. In a zero based array:

a.) the array length is a lot larger than the upper bound.

b.) the array length is one larger than the upper bound.

c.) the array length equals the upper bound.

d.) the array length is one less than the upper bound.

e.) the array length is a lot less than the upper bound.

Answer: b Level: Moderate

Section: 4-1 Page: 58

22. An array is:

a.) a collection of related data items.

b.) a collection of data elements.

c.) a collection of indexes.

d.) Both a and b.

e.) All of the above.

Answer: d Level: Hard

Section: 4-1 Page: 58

23. Each element has its own:

a.) array.

b.) upper bound.

c.) index.

d.) zero base.

e.) All of the above.

Answer: c Level: Easy

Section: 4-1 Page: 58

24. An index can be of the data type:

a.) decimal.

b.) currency.

c.) integer.

d.) long.

e.) string.

Answer: c Level: Moderate

Section: 4-1 Page: 59

25. Which can be used as an index in an array?

a.) constant

b.) variable

c.) expression

d.) Both a and b.

e.) All of the above.

Answer: e Level: Easy

Section: 4-1 Page: 59

26. If the index value is larger than the upper bound then:

a.) the closest data element will be used.

b.) an out-of-bounds error will occur.

c.) a division by zero error will occur.

d.) the first data element will be used by default.

e.) None of the above.

Answer: b Level: Easy

Section: 4-1 Page: 59

27. Arrays are especially useful in conjunction with:

a.) For Loops.

b.) If statements.

c.) Input statements.

d.) Output statements

e.) None of the above.

Answer: a Level: Moderate

Section: 4-1 Page: 60

28. Which Visual Logic command is used to create an array?

a.) Create Array

b.) Declare Array

c.) Make Array

d.) Instantiate Array

e.) Build Array

Answer: c Level: Easy

Section: 4-1 Page: 59

29. Which two components are found in the Make Array edit dialog box?

a.) Array Source and Lower Bound

b.) Array Name and Lower Bound

c.) Array Source and Upper Bound

d.) Array Name and Upper Bound

e.) Array Source and Array Name

Answer: d Level: Moderate

Section: 4-1 Page: 59

30. In a bubble sort how many extra storage variables are needed to re-arrange the two target numbers.

a.) 0

b.) 1

c.) 2

d.) 3

e.) It depends on how the number of elements in the array.

Answer: b Level: Moderate

Section: 4-6 Page: 73

31. Which is true about parallel arrays?

a.) They must have the same data types.

b.) They can have the same data types.

c.) They can have different data types.

d.) They must have different data types.

e.) Both b and c.

Answer: e Level: Moderate

Section: 4-6 Page: 70

32. The primary use of parallel arrays is to:

a.) hold multiple pieces of information about the same individual.

b.) sort through data to find the highest values.

c.) sort through data to find the lowest values.

d.) re-arrange a list of numbers to go from the highest to lowest values.

e.) None of the above.

Answer: a Level: Hard

Section: 4-6 Page: 70

Fill in the Blank Questions

33. The data values of an array are called ___elements___.

Level: Easy

Section: 4-1 Page: 58

34. A set of related data values is best held in a(n) ___array___.

Level: Easy

Section: 4-1 Page: 58

35. A(n) ___index___ is used to specify each element of an array.

Level: Easy

Section: 4-1 Page: 58

36. The first element of a zero-based array has an index value of ___zero___.

Level: Easy

Section: 4-1 Page: 58

37. The index value of the last element of an array is equal to the ___upper bound___.

Level: Moderate

Section: 4-1 Page: 58

38. A(n) ___out-of-bounds error___ occurs when an index value is used that is larger then the upper bound value.

Level: Moderate

Section: 4-1 Page: 59

39. The ___Make Array___ command opens the Mark Array edit dialog box.

Level: Easy

Section: 4-1 Page: 59

40. Two methods for finding the largest value involve using either a(n) ___index___ or ___value___ placeholder variable.

Level: Hard

Section: 4-2 Page: 63

41. Two arrays linked by the position of the data elements are called ___parallel arrays___.

Level: Easy

Section: 4-6 Page: 70

42. A simple method to sort an array so that its values are in order is a ___bubble___ sort.

Level: Easy

Section: 4-6 Page: 72

Essay Questions

43. Explain how an array is used to find the lowest value of 10 scores entered into a program.

• Create an array of size 10 (upper bound 9)

• Create a variable to hold the lowest value (or index of the lowest value)

• Input the 1st score

o Store the value of the score in the 1st array element

o Store the value in the lowest variable

• Input each score

o Store the value of the score in the ith array

o Test to determine if the new score is larger than the value in the lowest variable

▪ If the new score is lower, replace the current value with this new value

o Repeat inputting scores until all 10 scores are entered (index = 9)

• Create an output statement stating the lowest value

44. What is an array? How is it useful? What is the upper bound property of an array?

An array is a collection of data elements used to hold the same information associated with multiple individuals such as the grades for all of the students in a class. The collection of data elements are like individual variables, the advantage being the developer does not have to know how many data elements are needed when the program is created. The number of elements in an array can be determined dynamically when the program is running, while the declaration of variables must be done when the program is designed.

Each data element has an associated index that allows access to the data element. Arrays are typically zero-based, which means the first element has an index of zero. If the array has N data elements, then the last data element will have an index of N-1. This index for the last element is also called the Upper Bound. Using an index value larger than the Upper Bound will cause an out-of-bound error.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download