Please state the source of the article. Welcome to add Echo wechat (wechat id: T2421499075) for exchange and learning.


What is a data structure

A data structure is a way of storing and organizing data in a computer.

Data structure is a set of data elements which have certain logical relation, apply some storage structure in computer, and encapsulate corresponding operation. It contains three aspects: logical relation, storage relation and operation.

Different kinds of data structures are suitable for different kinds of applications, and some are even specialized for specific job tasks. For example, computer networks rely on routing tables to operate, and B-tree height is suitable for database encapsulation.

Why learn about data structures and algorithms?

As applications become more complex and data rich, millions, billions, or even billions of pieces of data appear, and the ability to search, insert, or sort such large pieces of data becomes slower and slower. Data structures are designed to solve these problems.

Are data structures far from us?

In fact, data structures are not that far away from us. As a Java programmer, we often work with many kinds of data structures, such as arrays, linked lists and queues, and stacks and heaps applied in the JVM. Is there anything else besides these? In fact, there are many more, such as the index in the database, may be the application of hash table, most of the tree structure. After counting, does the data structure still feel far away from us?

Details of common data structures

  • Stack: A Stack is a special linear table that can insert and delete data nodes at a fixed end of a table.
  • Queue: A Queue, like a stack, is a special linear table. Unlike stacks, queues only allow inserts at one end of the table and deletions at the other.
  • Array: An Array is an aggregate data type, which is an ordered collection of variables of the same type.
  • Linked List: A Linked List is a data structure in which data elements are stored according to a Linked storage structure that is physically discontinuous.
  • Tree: A Tree is a typical nonlinear structure. It is a finite set K with 2 nodes.
  • Graph: A Graph is another nonlinear data structure. In graph structures, data nodes are generally called vertices, and edges are ordered pairs of vertices.
  • A Heap is a special tree data structure. The Heap in general is a binary Heap.
  • Hash table: Hash table is derived from the Hash function. The idea is that if there is a record in the structure whose key is equal to T, it must be found in the storage location of F(T). In this way, it can be retrieved directly without comparison.

How do I choose a data structure?

These are the main considerations in choosing a data structure: the size of the first data; Characteristics of the second data; What is the third function oriented; Fourth, the use of a data structure storage, is not to the advantages of this data structure;