当前位置:网站首页>Array structure collation

Array structure collation

2022-06-25 10:34:00 m0_ forty-nine million four hundred and seventy-one thousand si

What is an array structure ?

The array structure is Computer Storage organization The way of data . Data structures refer to the relationships between There is Of one or more specific relationships data Set . The structure includes Logical structure and Physical structure

Data Logical structure Include 4 Kind of :

(1) aggregate : Between data elements except Same data type Nothing else

(2) Linear structure : Between the data elements is one-on-one —— The linear table , Stack , queue

(3) A tree structure : Between the data elements is One to many The relationship between

(4) Figure structure : The data element is Many to many The relationship between

Physical structure Include Sequential storage And Chain store

(1) The sequential storage structure is Use a continuous storage space To store data elements , Random access is possible , High access efficiency .

(2) The chain storage structure is Use any storage space To store data , No random access , Inefficient access

The head pointer and Head node The difference between :

(1) The head pointer : yes Point to First node Storage location The pointer to , have identification effect , The pointer head is Linked list Necessary elements of , Whether the list is empty or not , The head pointer exists

(2) Head node : yes Put it in First element Before the node , Easy to do before the first element node Insert and Delete The operation of , The head node is not a required element of the linked list , not essential , The data field of the header node may not store any information

Linear structure Characteristics :

(1) There must be a unique in the set “ First element ”

(2) There must be a unique in the set “ The last element ”

(3) Except for the last element , Other data elements have unique “ The subsequent ”

(4) Except for the first element , Other data elements have unique “ Forerunner ”

Array and Linked list The difference between :

(1) from Logical structure Come on : Array Storage length yes Fix Of , Can't adapt to Dynamic increase and decrease of data . Linked list can Dynamic allocation Storage space to adapt to the dynamic increase and decrease of data , Easy to insert and delete

(2) from access Look at : An array is a contiguous piece of storage space in memory , The array can be accessed randomly through the array subscript , Access efficiency is high . A linked list is a linked storage structure , Storage space does not have to be contiguous , It can be arbitrary , Access must be done from front to back , The access efficiency is lower than that of array .

If from the first i Insert multiple elements at multiple locations , For arrays, each insertion requires moving the elements back , The time complexity of each time is O(n), The single linked list only needs to be found for the first time i Location The time complexity is O(n), The time complexity of other insertions and deletions is O(1), Improve the efficiency of insertion and deletion

Single chain list The structure and Sequential storage structure

(1) When deleting and inserting , Sequential storage structures need to move elements every time , The total time complexity is O(n2)

(2) The chain storage structure is determined i After the pointer of position , Its time complexity is only O(1).

The order The storage structure needs to pre allocate memory space , So it will cause space waste or overflow . The chain The storage structure does not require pre allocated storage space , There is no limit to the number of elements .

Stack and queue The difference between :

(1) queue Is allowed to In one paragraph Insert   At the other end Delete Of The linear table , For the elements entering the queue, press “ fifo ” Rule processing of , stay Header To delete , stay Tail Insert .

(2) Stack It can only At the end of the table For insertion and deletion The linear table , For elements inserted into the stack, press “ Last in, first out ” Rule processing of , Both insert and delete are performed at the top of the stack , Because the stack entry and exit are carried out at the top of the stack , So there has to be a size Variable records the current stack size , When entering the stack size Cannot exceed array length ,size+1, Stack is not empty when exiting ,size-1

Reference resources : Data structure interview questions and answers sorting _けいしん The blog of -CSDN Blog _ Data structure interview questions

原网站

版权声明
本文为[m0_ forty-nine million four hundred and seventy-one thousand si]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251014391129.html