# Review Questions

 1: How many dimensions does the array warpedWorld have if accessing one of its elements requires a line of code like the following: ` warpedWorld[2,4,1,6,4] ` How many nested for loops would be required to access all elements in the warpedWorld array? 2: You are considering writing a chess-playing program. How many dimensions would the array representing the chessboard need to have? 3: Declare a rectangular three-dimensional array called observations with base type uint. Assign to it a reference to a new array object with the following numbers of elements in each dimension 5, 10, 20. Write a statement that assigns the value 100 to the observations element with indexes 3, 2, 10. What happens if you attempt to access the element with indexes 1, 12, 14? d. Write nested for loops to access and print onscreen the value of each element in the observations array. Use the foreach loop to perform the same operation as in question d. 4: Declare a jagged two-dimensional array called numbers of base type int, in which the first dimension contains 7 elements. Declare the third element of the first dimension to contain a one-dimensional array of length 20. Assign the value 100 to the fourth element in the array contained in the third element of the first dimension. 5: Suppose an array called numbers is declared as follows: ` int [] numbers = {2, 4, 6, 8, 10, 12, 6} ; ` Which values do the following method calls return? System.Array.IndexOf(numbers, 6) System.Array.IndexOf(numbers, 7) System.Array.IndexOf(numbers, 2, 3) System.Array.LastIndexOf(numbers, 6) System.Array.Reverse(numbers) followed by System.Array.IndexOf(numbers, 12) 6: Suppose that your program is searching an array containing one million data items by using the binary search algorithm. How many data items does it discard (and need not to look at again) from the search during the first search loop? 7: Your program needs to search for a value in an array of length 2048. What is the maximum number of loops required to find the value by using a Sequential search Binary search

C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon