Brief description of data structure, time and space complexity, recommended learning websites

Table of contents

IT Learning Route

Related Tough Book

Related interesting/readable books or videos

Recommended data structure and algorithm learning websites

Review questions

Time and space complexity

Brief description of data structure

basic concept


A brief introduction to data structures and algorithms and a review of CS. This article is not a basic tutorial . This article will list a large number of learning and reference websites. As is the old practice, an article is a collection (this article uses voice input (PC version of iFlytek input method) to speed up coding, but still maintains a concise style of writing).

Data structure + algorithm = program. Data structure: modeling of real-life problems that is consistent with computer storage; algorithm: steps to solve real-world problems (consistent with finiteness, certainty, feasibility, etc.).


IT Learning Route

  1. C language basics (you can read books, Bilibili, etc.) →

  2. The Three Musketeers of C Language: "C and Pointers", "C Traps and Defects" and "C Expert Programming", classics that will last forever →

  3. Data structures and algorithms (linear table/tree/graph/hash + sorting/search/planning, etc., learn on demand) →

  4. Computer science disciplines. "Principles of Computer Composition"/"Computer Architecture"; "Computer Operating System"/"Modern Operating System"/"In-depth Understanding of Computer Systems"; optional "Compilation Principles" and "In-depth Analysis of GCC"; network protocols such as "Computer Network" ", "TCP-IP Detailed Explanation Volume 1/Volume 2/Volume 3", etc. →

  5. Optional "Introduction to CPU Customization" →

  6. Direction: Embedded Linux direction, FPGA/chip design/verification direction, specific algorithm direction (such as CV, ML, DL), etc.

For more details, please refer to the summary of rd2coding/Road2Coding: Road to Programming (github.com) , which is more comprehensive.

Related Tough Book

Just search for the name without giving a link.

  • Which "Data Structures and Algorithms" book is the best? - Zhihu (zhihu.com) This answer lists some good books on data structures and algorithms.

  • "Introduction to Algorithms" (Classic) is an introductory book on algorithms in the computer science discipline.

  • "Computer Architecture" (Classic), "Computer Operating System"/"Modern Operating System"/"In-depth Understanding of Computer Systems".

  • "The Secret of Coding", related introduction/recommendation I want to practice the knowledge in "The Secret of Coding", what software is helpful? - Zhihu (zhihu.com) . "Compilation Principles" (classic), "In-depth Analysis of GCC".

  • Network protocols such as "Computer Network" and "TCP-IP Detailed Explanation Volume 1/Volume 2/Volume 3". If you  want to learn more about the HTTP protocol, what are the recommended books? - Zhihu (zhihu.com) .

  • Embedded application related: "GNU Make", "Debugging with GDB", "Linux Advanced Program Development", "POSIX Multi-Threaded Programming", "Embedded Linux Basic Tutorial", "Embedded Linxu Application Development Complete Manual", " Detailed explanation of embedded Linux application development.

  • Embedded bottom-level related: Kernel related: "In-depth understanding of the Linux kernel", "Linux kernel source code scenario analysis", "Linux kernel design and implementation"; driver related: "Linux device driver", "Linux device driver development detailed explanation", "Introduction and Practice of Linux Driver Development".

Related interesting/readable books or videos


Recommended data structure and algorithm learning websites

Review questions


Time and space complexity

Time complexity represents the order of magnitude in which the number of executed statements within an algorithm increases in the worst case as the number of loops n increases. The number of times a statement is used (frequency) in an algorithm is expressed as f(n), n is the number of loops in the algorithm, and changes in n directly change the number of statements used in the entire algorithm; the time complexity is O(g(n)) The definition of is that for an algorithm, if and only if there are positive integers c and n0 such that f(n) ≤ cg(n) holds for all n ≥ n0, then the asymptotic time complexity of the algorithm is f(n) = O(g(n)), g(n) is a function of n.

Comparison of the growth rate of statement frequency for each time complexity: O(log_2(n)) < O(n) < O(n*log_2(n)) < O(n^2) < O(n^3) < O(2^n) < O(n!), the first three are good, the last two are unacceptable, and the rest are unsatisfactory.

The execution time of the program not only depends on the size of the problem, but may also change with the status of the data, that is, its time complexity will change. Generally, the worst-case time complexity is used when evaluating algorithms.

The space complexity is much the same.

Brief description of data structure

For a software project, if the data structure is well designed, it will be particularly convenient to call, modify, and query when implementing functions later, which can achieve twice the result with half the effort.

basic concept

Several categories of data structures

  • Linear table:

    • order(array),

    • Linked list (linked list (singly linked list, doubly linked list, circular linked list (one-way, two-way), static linked list (implemented with the help of array))),

    • Special (stack (FILO), queue/heap (FIFO)).

  • Tree: binary tree, red-black tree, etc.

  • Graph: undirected graph, directed graph, etc.

  • Index/Hash: Maps, Hash Table.

Divide according to relationship

  • According to the logical relationship (connection relationship of elements):

    Collection, linear (array, stack, queue/heap, linked list, etc.), tree (one-to-many), graph (many-to-many).

  • According to storage relationship:

    • Sequential storage: such as arrays, you need to apply for space in advance (static allocation (performed at compile time) or dynamic allocation (malloc & free)). Advantages: The physical location is continuous and compact, and can be accessed randomly/directly; Disadvantages: Memory fragmentation will occur, and changes must be followed when adding, deleting or changing (a large number of elements need to be moved).

    • Linked storage: such as linked lists, trees, and graphs, you must apply for space in advance (dynamic allocation (malloc & free)). Advantages: chained, discrete, node-based, space can be dynamically allocated, easy to change (change the direction of the node); Disadvantages: large space occupation, inconvenient search (need to traverse the entire linked list).

    • Index storage: The structural form of "index-data" (Key-Value, also called Maps). "map" in Java and C++, and "dictionary" in Python.

    • Hash storage: such as hash table (Hash Table), etc.

Data operations

  • The basic operations to be implemented by each basic data structure are: add (insert), delete (delete), change (update), check (retrieval), judge (empty, full), sort (sort), reset (reset).

  • More complex operations can be implemented using the above basic operations.

The time complexity of the operation

The specific concepts are mentioned in the "Time and Space Complexity" section of the article " C & MCU Writing Specifications and Others ". (Data structure) Time complexity can be solved in ten minutes (time complexity of algorithm) - Jianshu (jianshu.com) . A set of diagrams to understand "time complexity"_ 12 26 25's blog - CSDN Blog_Time Complexity .

  • Search: O(1) for sequential storage structure, O(n) for singly linked list.

  • Insertion and deletion: O(n) for sequential storage structure, O(1) for singly linked list.

Guess you like

Origin blog.csdn.net/Staokgo/article/details/132922442