java -- data structure summary

java -- data structure summary

 

 

concept

 

Data structure: The relationship between data to improve program efficiency.

 

 

Logical relationship: think think think

 

Collection: There are multiple data in a range, no relationship between data

Linear: one-to-one relationship

Tree shape: one-to-many

Figure: Many-to-many

 

 

Physical relationship: memory storage

 

Sequential Storage: Array

Linked Storage: Linked List

 

 

question

 

Are data structures difficult? easy but hard

Does it work? Useful and useless, you may not be able to use it at work, but you can learn programming ideas

 

 

 

 

algorithm

 

Storage of large numbers, operation of large numbers

 

    Both int and bigint have a limit on the size of numbers, so they can be stored in arrays, and an array of length 100 can store very large numbers. For example: 372*18



 

 

Multiplying two large numbers? ?

 

 

sort

 

Insertion sort, Hill sort

selection sort, heap sort

bubble sort, quick sort

merge sort

radix sort

 

 

find

 

Binary search (index of database)

 

 

 

 

Common data structures

 

ArrayList: dynamic array, when the capacity is insufficient, it will automatically expand to 1.5 times + 1

 

LinkedList: Doubly circular linked list, no need to expand

Single list

one-way circular linked list

doubly linked list

doubly linked list

 

 

Compare

 

Add: LinkedList is efficient, and the slowest addition is the slowest, because the last one is known from the first one, because the ArrayList may need to be expanded

Delete: The efficiency of LinkList is still high, and the deletion is the slowest in the middle. The efficiency of ArrayList deletion from front to back is too low. It is better to delete from back to front. Note: When cyclic deletion, you must traverse from back to front.

Get and set: LinkedList is inefficient, ArrayList is an array, so it is much more efficient

 

 

 

Guess you like

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