Front-end interview skills collection No. 22 blog post - high-frequency test points (common data structures)

This is a record 前端面试的话术集锦第二十二篇博文——高频考点(常见数据结构)and I will keep updating this blog post. ❗❗❗

People often ask: Is learning data structures or algorithms useful for front-end engineers?

In general, these basic disciplines do have little effect in the short term, but let's not limit ourselves to front-end engineers. When we look at programming from the perspective of programming, data structure algorithms must be useful, and they are also a ceiling for your future.

You don’t need to spend concentrated time learning these contents, but you must learn a little bit from time to time, because these skills can really improve your ability to write code.

1. Time complexity


Before getting to the point, let’s first understand what time complexity is.

The worst time complexity is usually used to measure the quality of an algorithm.

Constant time O(1)means that this operation has nothing to do with the amount of data. It is a fixed-time operation, such as the four arithmetic operations.

For an algorithm, the number of operations may be calculated as aN + 1, Nrepresenting the amount of data. Then the time complexity of the algorithm is O(N). Because when we calculate the time complexity, the amount of data is usually very large, and low-order terms and constant terms can be ignored at this time.

Of course, it may happen that both algorithms have O(N)the same time complexity, so comparing the quality of the two algorithms depends on comparing the low-order terms and constant terms.

2. Stack

2.1 Concept


The stack is a linear structure and a fairly common data structure in computers.

The characteristic of the stack is that data can only be added or deleted at one end, following the first-in, last-out principle:

Guess you like

Origin blog.csdn.net/lvoelife/article/details/132871618