multidimensional arrays and generalized tables of data structure exercises

Source: Internet
Author: User
Tags ranges

Chapter Fifth multidimensional arrays and generalized Table

I. Basic requirements, key points and difficult points

The purpose of this chapter is to introduce the logical structure characteristics of multidimensional arrays and how to store them. A compression storage method for special matrices and sparse matrices. The focus of this chapter is familiar with the storage of multidimensional arrays, the compression storage of matrices, and the difficulty is the algorithm implemented by the compressed storage of sparse matrices.

Second, the examination target, the examination request

1. Multidimensional arrays that require an "understanding" level

1.1 The logical characteristics of a multi-dimensional array.

1.2 The sequential storage structure of multi-dimensional arrays and the method of address calculation.

The 1.3 array is the reason for a random access structure.

2. The compression of the matrix storage, the need to reach the "understanding" level

2.1 Concepts of special matrices and sparse matrices.

2.2 The method of subscript transformation when compressing storage of special matrix.

2.3 The method of ternary table representation of sparse matrices and the related algorithms.

Three, exercises

1. Single-Choice questions

1.1 The element of the two-dimensional array m is a string of 4 characters (each of which occupies a single storage unit), the range of subscript I is from 0 to 7, and the column subscript J ranges from 0 to 9. The number of storage units required to store M is (D)

A) (+ B) 480 C) (D) 320

Gaze: by title: 8*10*4=320.

1.2 N is a 5x8 two-dimensional array that represents the 10th element of the array when n is stored in row-first mode (C)

A) n[2][2] B) n[2][1] C) n[1][1] D) n[1][2]

Gaze: The element of the tenth element of the array of five rows of eight columns is the n[1][1] element as the second row of the secondary column.

1.3 The element of a two-dimensional array m[i][j] is a string of 4 characters (each of which occupies a single storage unit), the range of subscript I is from 0 to 4, the range of subscript J ranges from 0 to 5,m by row storage when the starting address of the element m[3][5] and M is stored by column the same element as the address address is (B)

A) m[2][4] B) m[3][4] C) m[3][5] D) m[4][4]

Gaze: The storage address that is known by the title as the first line is: 4*6*4=96.

The same vegetarian address element that is stored by column precedence is: m[3][4].

1.4 Sparse matrices generally have two methods of compressing storage, i.e. (D)

A) Two-dimensional arrays and three-dimensional arrays B) triples and hashes

C) hash and cross-linked list D) triples and cross linked lists

The two basic operations of the 1.5 constant array are (C)

A) Create and delete B) indexes and changes

C) Find and change D) find and Index

1.6 Set matrix A is a symmetric matrix, in order to save storage space. The lower triangular section (see Figure 5.1) is stored in a one-dimensional array sa[0..n (N+1)/2], with the triangle element aij (I≥J). The value of the subscript position K in the one-dimensional array sa is (B)

A) j* (j-1)/2+i-1 B) i* (i+1)/2+j

C) j* (j+1)/2+i-1 D) i* (i-1)/2+j

gaze: For symmetric matrices, the value of the subscript position is: i* (i+1)/2+j.


2. Fill in the blanks

2.1 Known two-dimensional array a[m][n] is stored in the main way of the row order. Each element occupies a K storage unit, and the storage address of the first element is LOC (a[0][0]), then the address of A[i][j] is [loc[(a[0][0]) + (N*I+J) K]].

2.2 Two-dimensional array a[10][20] The address of the a[6][12] is [332] when the row order is used as the primary store, each element points to a storage unit, and A[0][0] 's storage address is 200.

Gaze: Use the formula to calculate the address as: 200+6*20+12=332

2.3 There is a 10-order symmetric matrix A, which is used as a compressed storage method (mainly stored in line order, and A[0][0]=1). The address of a[8][5] is [42].

Gaze: Because it is a symmetric matrix, the address is calculated using the formula: 1+8* (8+1)/2+5=42

multidimensional arrays and generalized tables of data structure exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.