Data Structure and Algorithm Analysis - Basic Concepts

basic concept

Examination Content

Definition of data, data elements, data items, data objects, data structures

data:

It is a symbolic representation of objective things, and it is a general term for all symbols that can be input into a computer and processed by a computer program.

Data Elements:

A data element is the basic unit of data that is usually considered and processed as a whole in a computer.

In some cases, data elements are also referred to as elements, records, and so on.

Data elements are used to fully describe an object, such as a student record in the example in the previous section, a pattern (state) of a chessboard in a tree, and a vertex in a graph, etc.

data item:

A data item is the smallest indivisible unit that constitutes a data element and has independent meaning.

data object:

A data object is a collection of data elements of the same nature, which is a subset of data.

Regardless of whether the set of data elements is an infinite set (such as an integer set), or a finite set (such as an alphabetical character set), or a set of compound data elements (such as a student table) composed of multiple data items, as long as the properties of the elements in the set are the same The same, can be called a data object.

data structure:

Data structures are the way computers store and organize data.
A data structure is a collection of data elements that have one or more specific relationships with each other.
The data structure reflects the internal composition of the data, that is, which part of the data is composed, in what way, and the structure presented between data elements.

Definition of logical structure of data, physical structure of data, and operation of data

Logical structure:

The logical structure of the data is to describe the data from the logical relationship, it has nothing to do with the storage of the data, it is independent of the computer. Therefore, the logical structure of data can be seen as a mathematical model abstracted from concrete problems.
The logical structure of data has two elements: one is the data element; the other is the relationship.

Physical structure:

The storage representation of a data object in a computer is called the storage structure of the data, also known as the physical structure.
When storing data objects in a computer, it is usually required to store not only the data of each data element, but also the logical relationship between data elements, and a data element is represented by a node in the computer.
There are two basic storage structures for data elements in computers, namely sequential storage structure and chain storage structure.

Data types and definitions of abstract data types

type of data:

Data type (Data Type) is a basic concept in high-level programming language.
A data type is a general term for a set of values ​​and a set of operations defined on this set of values.

Abstract data type:

Abstract Data Type (Abstract Data Type, ADT) generally refers to the mathematical model defined by the user, which represents the application problem, and the general term for a set of operations defined on this model. It specifically includes three parts: data objects, data objects, and relationships A collection of collections and basic operations on data objects.

exam requirements

Relationships between data, data elements, and data items:

Data element: Data element is the basic unit of data
Data item: Data item is the indivisible smallest unit of data

Master the three elements of data structure

Logical structure
Storage structure
Data operation

Relationship between data types, abstract data types, and data structures

Algorithms and Algorithm Analysis

Examination Content

The definition of algorithm, the characteristics of algorithm, the definition and calculation of the time complexity of algorithm and the space complexity of algorithm

algorithm:

It is a finite sequence of operations prescribed to solve a certain type of problem.

Features of the algorithm:

Finiteness : An algorithm must always end after executing a finite number of steps, and each step must be completed in finite time.

Determinism : The operation that should be performed in each case has exact regulations in the algorithm, and there will be no ambiguity, so that the executor or reader of the algorithm can clearly understand its meaning and how to execute it.

Feasibility : All operations in the algorithm can be realized by executing the basic operations already implemented for a limited number of times.

Inputs : An algorithm has zero or more inputs. When describing an algorithm with a function, the input is often represented by formal parameters, and when they are called, the input value is obtained from the calling function.

Output : An algorithm has one or more outputs, which are the results of information processing by the algorithm, and an algorithm with no output has no meaning. When using a function to describe an algorithm, the output is usually represented by a return value or a reference type parameter.

time complexity:

The number of repeated executions of a statement is called the statement frequency;

In general, the number of repeated executions of basic statements in the algorithm is a certain function f(n) of the problem size n, and the time measurement of the algorithm is recorded as: T(n)= O(f(n));

It means that as the size of the problem n increases, the growth rate of the algorithm execution time is the same as the growth rate of the function, which is called the asymptotic time complexity of the algorithm, or time complexity for short.

Space complexity:

Regarding the storage space requirements of the algorithm, it is similar to the time complexity of the algorithm

We use asymptotic space complexity (Space Complexity) as the degree of storage space required by the algorithm, referred to as space complexity, which is also a function of the problem size n, recorded as: S(n) = O(f (n))

exam requirements

Algorithm definition and properties

Criteria for evaluating the pros and cons of an algorithm:

Determinism : With reasonable data input, the correct result can be obtained within a limited running time.

Readability : A good algorithm should firstly allow people to understand and communicate with each other, followed by machine executable. A readable algorithm helps people understand the algorithm, while an incomprehensible algorithm is easy to hide errors, and difficult to debug and modify.

Robustness : When the input data is illegal, a good algorithm can properly react or process accordingly without producing some inexplicable output results

Efficiency : Efficiency includes two aspects of time and space . Time efficiency means that the algorithm design is reasonable and the execution efficiency is high, which can be measured by time complexity; space efficiency means that the algorithm occupies a reasonable storage capacity, which can be measured by space complexity. Time complexity and space complexity are the two main indicators to measure the algorithm

Understand the two aspects of measuring algorithms on resources

time complexity

space complexity

Master the progressive analysis method of the algorithm, and use this method to evaluate the algorithm

Explanation video link – Professor Qu Wanling of Peking University

Progressive analysis:

Calculate the growth trend of time and space required by the algorithm by increasing the input size

Master the Ο notation and understand the meaning of the big Ο notation

O notation:

For f(n), there are positive numbers n0,c, so that when n>=n0, there is always 0 <= f(n) <= c*g(n), then we can use f(n)=O( g(n)) means.

The O notation is suitable for mathematical notation that describes the asymptotic behavior of a function, using another function to describe the asymptotic upper bound of the magnitude of a function

Master the Ω notation and understand the meaning of the big Ω notation

Ω notation:

For f(n), there are positive numbers n0 and c, so that when n>=n0, there is always 0 <= c*g(n) <= f(n), then we can use f(n)=Ω( g(n)) means.

defines the asymptotic lower bound of the algorithm

Master the Θ notation and understand the meaning of the big Θ notation

Θ notation:

For f(n), there are positive numbers n0, c1, c2, so that when n>=n0, there is always 0 <= c1 g(n) <= f(n) <= c2 g(n), then we can Expressed by f(n)=Θ(g(n)).

defines a precise asymptotic behavior

Understand the space-time trade-off principle

Space-time trade-off principle:

A method of solving a problem by reducing or increasing the space efficiency of the algorithm to increase or decrease the time efficiency.

Guess you like

Origin blog.csdn.net/weixin_45976751/article/details/121179139