In depth understanding of ArrayList and LinkedList, source code analysis and performance testing

Spoiler: ArrayList's insertion and query operations are much faster than LinkedList ArrayList characteristic The bottom layer is realized by array, with fast query speed and slow addition, deletion and modification speed (in theory) Thread unsafe Common methods of ArrayList import java.util.ArrayList; import java.util.Iterator; import jav ...

Posted by cyrixware on Wed, 25 May 2022 15:49:26 +0300

Three common implementation classes of Java List interface

List three common sets ArrayList (key) ArrayList is a typical implementation class and main implementation class of the List interface. In essence, ArrayList is a "variable length" array of object references. summary ArrayList class is an array that can be dynamically modified. The difference from ordinary arrays is that it has no f ...

Posted by techcone on Sun, 22 May 2022 10:18:32 +0300

[Data structure] chain stack

definition Chained stack is a data storage structure, which can be implemented in the form of a singly linked list. The advantage of using a chained stack is that it can overcome the low space utilization of sequential stacks implemented with arrays, but it needs to be used for each stack element. Allocate additional pointer space for storing ...

Posted by roughie on Sun, 22 May 2022 02:28:20 +0300

JAVA data structure and algorithm -- single chain surface test questions (Sina, Baidu, Tencent)

Common interview questions of single linked list Find the number of effective nodes in the single linked list Find the penultimate node in the single lin k ed list (Sina) Reversal of single linked list (Tencent) Print the single linked list from end to end (Baidu requires mode 1: reverse traversal. Mode 2: stack stack) Example 1: find the ...

Posted by lin on Sat, 21 May 2022 17:37:32 +0300

Big talk data structure - Summary

Big talk data structure - Summary Read the book "Dahua data structure" and summarize some things; The summary is rough. Some ideas can't be understood for the time being. Put them aside first, and then go back to digest these knowledge points after learning other things 1. Data structure A data structure is a collection of ...

Posted by redrabbit on Sat, 21 May 2022 01:17:44 +0300

P1792 [national training team] planting trees

Problem surface Luogu preface At the beginning, I don't want to write this question, because I can't write a linked list (it seems that I haven't written it several times). Finally, with the encouragement (oppression) of the coach, he made up for his knowledge about the linked list and barely passed the problem. (after all, the linked list was ...

Posted by pablocullen on Fri, 20 May 2022 23:16:04 +0300

Java learning DAY16 list, iterator

List Implementation classes: ArrayList, LinkedList, Vector, Stack ***ArrayList: ***The bottom layer implements data storage by an array. The default initial capacity is 10. The bottom layer of the array is expanded by half according to the right shift operation. ***ArrayList (sequence list)***: The bottom layer is the data implemented by the ar ...

Posted by rmbarnes82 on Fri, 20 May 2022 19:51:40 +0300

[data structure and algorithm] stack and queue

Stack What is a stack? Stack is a kind of linear table. It only allows the insertion and deletion of elements at the fixed end. The one end for data insertion and deletion is called the top of the stack and the other end is called the bottom of the stack. Therefore, the stack addition and deletion elements have what we often call last ...

Posted by beboo002 on Fri, 20 May 2022 00:43:56 +0300

Simple implementation of linked list in Java

catalogue 1, Simple understanding of linked list 1. What does the linked list look like? 2. What is the node? 2, Code implementation of linked list 1. Construction of nodes 2. Construction of linked list  3. View linked list length 4. Find whether to specify whether the element is in the single linked list 5. Insert an element a ...

Posted by FMB on Sun, 15 May 2022 08:47:29 +0300

Linked storage structure -- implementation of one-way linked list (Java)

Data structure - one way linked list preface In the previous chapter, we implemented the linear table using the sequential storage structure. We found that the query efficiency of the linear table is very fast and the time complexity is O(1), but the efficiency of adding and deleting data is relatively low. Based on these problems, th ...

Posted by csueiras on Sun, 15 May 2022 01:28:35 +0300