Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the common basic data structure of Java

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you the relevant knowledge of what the common basic data structure of Java is. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

Stack:

Stack, also known as stack, is a linear table with limited operation, which only allows insert and delete operations at one end of the table, and does not allow add, find, delete and other operations in any other location.

To put it simply, the collection with this structure has the following characteristics for accessing elements.

1. Enter first and then leave later.

2. The entrance and exit of the stack are all at the top of the stack.

Stack pressing: the element is stored at the top of the stack, and the elements in the stack are moved one position at a time to the bottom of the stack.

Pop stack: take the element, take out the element at the top of the stack, and the existing elements in the stack move one position to the top of the stack in turn.

Queue:

Queue, or queue for short, is a linear table with limited operations, just like the stack, which only allows inserts at one end of the table and deletes at the other end of the table.

To put it simply, the collection with this structure has the following characteristics for accessing elements:

1. First in, first out

2. The entrance and exit of the queue are on each side, for example, the entrance on the left and the exit on the right

Array:

Array is an ordered sequence of elements. An array opens up a continuous space in memory and stores elements in this space. The corresponding data can be found quickly through the index.

Using this method to store data has the following characteristics:

1. Find the element quickly, and you can quickly access the element at the specified location through the index.

2. Adding and deleting elements is slow. If you add elements at the specified index location, you need to create a new array, store the specified new elements at the specified index location, and then copy the original array elements to the corresponding index position of the new array according to the index.

To delete elements, you need to create a new array, copy the original array elements to the corresponding index of the new array according to the index, and the specified index position elements in the original array are not copied to the new array.

Linked list:

Linked List, which consists of a series of node node, can be generated dynamically at run time. Each node consists of two parts: one is the data field in which the data elements are stored, and the other is the pointer domain in which the address of the next node is stored. Linked list is divided into one-way linked list and two-way linked list, two-way linked list refers to the reference of the previous node and the pointer of the next node, one-way linked list is the pointer of only the next node.

To put it simply, using the collection of this data structure, the storage of data has the following characteristics:

Multiple nodes are connected by address.

The query is slow, and if you want to find an element, you need to look backwards through the connected nodes.

Add and delete quickly, you only need to change the address of the next element.

Red and black trees:

Binary tree: an ordered tree with no more than 2 for each node

To understand simply, a binary tree is a tree structure in which each node has at most two subtrees. The top is called the root node, and both sides are called the left subtree and the right subtree.

The red-black tree itself is a binary search number, after the node is inserted, the number is still a binary search number, which means that the key value of the number is still in order.

The constraints of the red-black tree:

Nodes can be red or black

The root node is black

The leaf node is black.

The child nodes of each red node are black.

There are the same number of black nodes on all paths from any node to each of its leaf nodes

The characteristics of red and black trees:

The speed is very fast, approaching the balanced tree, searching for leaf elements at least and no more than twice as many times.

That's all of the article "what are the common basic data structures of Java?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report