Data Structures and Algorithms (1)

1. Stack

1. A data structure is a basic programming structure used to implement collections.

2. Stack stack: A linear collection. The elements of the stack are processed according to the last-in-first-out (LIFO) method. The elements that finally enter the stack are removed first, and the elements are added and deleted from the top .

3. Basic operation of stack:


4. Array-based stack: ArrayStack<T>

5. Stack based on linked list implementation:

The object reference variable stores the address of the object, indicating the storage location of the object in memory.

6. Linked list: LinkedStack<T>

A linked list is a chained structure in which one object can point to another object, thereby creating a linear order of objects in the linked list. The objects stored in the linked list are generally referred to as the nodes of the linked list -- node

A linked list consists of objects, where each object points to the next object in the linked list.

7. When adding a node at the front end of the linked list, you need to reset the reference to the entire linked list.

8. The Deque interface is implemented by the LinkedList class, which provides a linked list implementation of the stack.

2. Queue

Queue Queue is a linear collection,

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325164825&siteId=291194637