Introduction to Data Structure exercises

Source: Internet
Author: User

Introduction to Data Structure exercises

Chapter 1 Overview

I. Key points and difficulties of basic requirements

To learn this chapter, you must familiarize yourself with the meanings of terms and terms, and master various basic concepts, in particular, the logical structure, storage structure, and data operation of the data structure and their relationships; be familiar with the writing standards of C language and understand the exact meaning of the five elements of the algorithm, that is to say, there are poor, deterministic, feasible, and input and output, so as to grasp the frequency of computing statements and the method for estimating the time complexity of the algorithm, and lay the foundation for learning the data structure.

Ii. assessment objectives and requirements

The basic concepts of data, data elements, data items, and data structures are required to reach the recognition level. The logical structure, storage structure, and data operation meanings of data structures and their relationships are also required; the two logical structures of the data structure and four common storage Representation Methods play a role in various software systems. Selecting the appropriate data structure is a key step to solve application problems.

Requirements must be met at the level of understanding: concepts such as algorithm, algorithm time complexity and space complexity, worst case time complexity and average time complexity; the time complexity of an algorithm depends not only on the scale of the problem, but also on the initial state of the input instance. The algorithm description and algorithm analysis method analyze the time complexity of a general algorithm.

Algorithms that require simple application include time complexity.

Iii. Exercise questions

1. Single-choice questions

1.1 In the data structure, the data structure can be logically divided into (B)

A) compact and non-compact structures

B) linear and nonlinear structures

C) internal structure and external structure

D) Dynamic and Static Structures

Logically, data structures can be divided into linear structures and Non-linear structures.

1.2 The sequential storage structure of linear tables is a (C) storage structure.

A) sequential access

B) index access

C) Random Access

D) hash access

The sequential storage structure of a linear table is a storage structure for random access. The chain storage structure of a linear table is a storage structure for sequential access.

1.3 logical relationships are exponential data elements ()

A) join

B) Storage Method

C) Structure

D) data items

1.4 The Worst of the following time complexity is (D)

A) O (1)

B) O (n)

C) O (log2n)

D) O (n2)

1.5 Which of the following is the most time complex? ()

A) O (1)

B) O (n)

C) O (log2n)

D) O (n2)

1.6 The following algorithms indicate that the time complexity is (D)

For (I = 0; I <n; I ++)

For (j = 0; j <n; j ++)

C [I] [j] = I + j;

A) O (1)

B) O (n)

C) O (log2n)

D) O (n2)

1.7 two main aspects of algorithm analysis: (D)

A) Correctness and simplicity

B) Data complexity and Program Complexity

C) readability and maintainability

D) time complexity and space complexity

1.8 if A linear table is stored in A chained storage structure, the available storage unit address in the memory is required ()

A) not necessarily continuous

B) Some addresses must be continuous.

C) It must be continuous.

D) It must be discontinuous.

1.9 The algorithm refers to (D)

A) computer program

B) Calculation Method for Solving the Problem

C) Sorting Algorithm

D) finite Operation Sequence for solving the problem

1.10. The basic unit of data is (B)

A) File

B) data elements

C) symbol

D) KEYWORDS

2. Fill in blank questions

2.1 data structures generally include three aspects: [logical structure], storage structure, and data operation.

2.2 The operation for finding the location of the node that meets the conditions in Data Structure S is [Search]

2.3 read the content at the specified position from the data structure S: [read]

2.4 The operation for adding a node to a specified position in Data Structure S is [insert]

2.5 The operation to remove the node at the specified position from the data structure S is [delete]

2.6 The operation for modifying the content of a specified node in the structure from Data Structure S is [update]

2.7 The data storage structure (physical structure) can be represented by four Storage Methods: sequential storage, chained storage, [index Storage], and Hash Storage.

2.8 In addition to "correctness", the algorithm selection mainly includes [time required for Algorithm Execution], storage space required for Algorithm Execution, easy to understand, easy to program, and easy to debug.

2.9 The data structure is to study the physical structure and [logical operations] of the data and their relationships, and to define corresponding operations for such structures.

2.10 The Logical Structure of Data describes data in a logical relationship. It is independent of the [storage structure] of data and is independent of computers.

3. Short answer

3.1 briefly describe the relationship and difference between data and data elements

A: All objects that can be stored and processed by computers are collectively referred to as data. Data is a collection. A data element is the basic unit of data and an element of data. The relationship between data elements and data is the relationship between elements and sets.

3.2 brief introduction to concepts of data, data elements, data types, data structures, storage structures, linear structures, and non-linear structures

Answer: data is the carrier of information. It can be recognized, stored, processed, and processed by computers.

Data elements: the basic unit of data. Sometimes a data element contains several data items

Data Type: a set of values and a group of operations defined on these values.

Data Structure: refers to the logical relationship between data, also known as the logical structure of data. It includes two categories: linear structure and non-linear structure.

Storage Structure: the representation of data elements and their relationships in computer memory. It is called the storage structure of data.

Linear Structure: If the structure is not empty, there is only one Start Node and one terminal node, and all nodes have at most one direct precursor and one direct successor.

Non-linear structure: the logical feature of this structure is that a node may have multiple direct precursor and direct successor

3.3 briefly describe the main differences between the sequential storage structure and the chained Storage Structure in expressing the relationship between data elements

A: The sequential storage structure stores the storage locations of each data element in a continuous storage space based on the logical relationship between them, the storage location of data elements reflects the logical relationship between data elements. In a chained storage structure, data elements are not necessarily stored in a continuous storage space. The logical relationships between data elements and storage locations are not one-to-one, and the logical relationships between data elements, it is represented by a pointer attached to a node that stores data elements.

3.4 which of the following aspects is used to evaluate the algorithm quality?

A:

A. The algorithm must be correct.

B. Time spent on Algorithm Execution

C. The space used to execute algorithms, mainly considering the auxiliary storage space

D. algorithms should be easy to understand, easy to code, and easy to debug.

4. Application Questions

4.1 calculate the time complexity of the following algorithms

For (I = 1; I <= n; I ++)

{

Y = y + 1;

For (j = 1; j <= 2 * n; j ++)

X = x + 1;

}

A: The frequency of statement y = y + 1 is n-1, and the frequency of statement x = x + 1 is (n-1) (2n + 1 ). So the algorithm time complexity of this program is: T (n) = O (n-1) (2n + 1) = O (n2)

4.2 calculate the time complexity of the following algorithms

X = 1;

Sum = 0;

For (I = 1; I <= n; I ++)

{

X = x * I;

Sum = sum + x;

}

A: Since the deepest nested statement frequency is n, the time complexity of the algorithm is O (n ).

Related Article

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.