1. A queue can be seen as a collection of two ports. One port is called the first and the other is called the end of the team. You can only Delete the first port and insert it at the end of the team. Follow these steps. The queue features first-in-first-out. 2. A stack can be regarded as a set of one port, which is called the stack top. Insert and delete operations can only be performed at the top of the stack. Follow these steps. The feature of the stack is that the chain table is stored inNon-contiguous memory spaceStores the elements of a set. 4. the array corresponds to it.In a continuous spaceThe element queue and stack of the storage set are typical representatives of linear data structures, while arrays and linked lists are two common data storage structures; queues and stacks can be stored in arrays or linked lists to implement their functions. arrays and linked lists: arrays are stored in sequential storage. Because the storage location of each element can be calculated by simple means, therefore, the time for accessing elements is the same (directly accessing the array subscript); The linked list belongs to the data link storage, because the storage location of each element is stored in its precursor or successor node, therefore, you can only access yourself by pointer after accessing its precursor node or its successor node. The time for accessing any element is related to the location of the element node in the Link storage.Linked lists and arrays are two common data storage structures that can be used to store specific types of data.
1. Occupied memory space
The memory space stored in the linked list can be continuous or non-consecutive, And the array is a continuous memory space. Generally, the storage of the same number of data arrays occupies a small amount of memory, and the linked list also needs to store the space of its predecessor and successor.
2. Length Variability
The length of the linked list can be scaled as needed, while the length of the array must be defined. If the number of data stored exceeds the initial size of the array, overflow occurs.
3. Access to Data
The linked list facilitates data movement and data access is troublesome; array access data is fast and mobile data is troublesome.The differences between linked lists and arrays determine their different use cases. If you need a lot of data access, arrays are suitable. If you need to perform many shift operations on the data, set and use the linked list.
What is the difference between stack and stack:
1. the stack has the characteristics of the stack in the data structure, and all the data stored in it is clearly defined in the lifecycle (of course, it must not be stored for too long, the occupied space is determined and the occupied space is small), which can be quickly reflected! All the eight basic data types and referenced variables stored in Java are destroyed immediately after they are used up.
2. Heap can understand that it is a large, small, and obedient memory operation unit you allocate. Therefore, heap features dynamic memory allocation and is suitable for storing enlarged data volumes! For example, all the information of an object, although its reference points to a reference variable in the stack, all Java stacks store new objects. Because of its different features, heap and stack are widely used in computers!