In JavaScript, a data structure refers to a collection of data elements that have one or more specific relationships with each other. It is a collection of data elements with structural characteristics. Commonly used data structures include: arrays, lists, stacks, queues, linked lists, dictionaries, sets, etc.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
In computer science, data structure (English: data structure) is the way computers store and organize data. A data structure refers to a collection of data elements that have one or more specific relationships with each other. Data structure originated from programming. It does not teach us how to code, but provides us with a programming idea and better ideas. Often, carefully selected data structures can lead to higher operating or storage efficiency. Data structures are often related to efficient retrieval algorithms and indexing techniques.
Effectively manage data objects
Improve computing performance
Data:
Data: It is a symbol (string, Numbers, json, sounds, pictures...) Data elements: the most basic units with a certain meaning. When we use computers to process data, data elements are usually processed by us as a whole. This whole is also called a record. Data object: refers to a collection of data elements with the same nature. Data item: is the smallest unit that makes up data.
Structure:
Data elements interact with each other. The relationship between them is called structure.
Structures are divided into two types:
Logical structure: refers to the data structure that reflects the logical relationship between data elements, where the logical relationship refers to the data The context relationship between elements, regardless of their storage location in the computer
Storage structure: refers to the storage form of the logical structure of data in the computer storage space
So, a data structure can be expressed as one or more storage structures
Logical structure:
Set: the data members in the set It is an unordered and loose relationship, and each data member cannot be repeated in the set. Linear structure: the elements in the data structure have a one-to-one relationship with each other. Non-linear structure: the elements in the data structure have one-to-many or many-to-many. The mutual relationship
Storage structure:
Sequential storage: Array is a typical sequential storage structure. Chained storage: Linked list uses chained storage. Index storage: Index storage The advantage is that the retrieval speed is fast, but additional index tables need to be added, which will occupy more storage space. Hash storage: Hash storage makes the operations of retrieving, adding, and deleting nodes very fast. The disadvantage is that resolving hash conflicts will increase the cost. Time and space overhead, commonly used methods to resolve hash conflicts include open chain method and linear detection method
Array:
A linear collection that stores elements. The elements can be accessed arbitrarily through the index. The index is usually a number and is used to calculate the offset of the storage location between elements. .
Lists:
People often use lists in their daily lives: to-do lists, shopping lists, top ten lists, Last ten list and more.
Stack:
is an efficient data structure, because data can only be added or deleted at the top of the stack, so like this The operation is fast and easy to implement.
Queue:
Queue is used to store data arranged in order, first in first out, which is different from stack
Linked list:
A linked list is a collection of nodes. Each node uses a reference to an object to point to its successor. A reference pointing to another node is called a chain
Dictionary:
A dictionary is a data structure that stores data in the form of key-value pairs. Just like names and phone numbers in a phone book.
Tree:
Tree is a data structure often used in computer science. A tree is a non-linear data structure that stores data in a hierarchical manner.
Trees are used to store data with hierarchical relationships, such as files in a file system; trees are also used to store ordered lists.
Graph:
The graph consists of a set of edges and a set of vertices.
Hash table:
Hashing is a commonly used data storage technology, and hashed data can be quickly inserted or retrieved. The data structure used for hashing is called a hash table.
Set:
A set is a data structure containing different elements. The elements in a set are called members.
The two most important characteristics of sets are: first, the members in the set are unordered; second, the same members are not allowed to exist in the set.
Commonly used data structures will be broken down one by one in the future!
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of What is JavaScript data structure. For more information, please follow other related articles on the PHP Chinese website!