A table is an abstract definition of arraylist,linkedlist,stack,queue. I understand it as an ordered single data store.
Use of the Remove method with the LinkedList class
Simulates a scene, iterates over a linkedlist, and deletes the values stored in them as even numbers.
- Method One: Use subscript I for A For loop, if found to be an even number, and then remove (i) to delete. The time complexity of this method is O (N2), because the complexity of the outer traversal is n, the memory is going to get (i) and remove (i) their complexity is n.
- Method Two: Using the enhanced for loop, an exception is generated: The enhanced for loop uses iterator during the loop, but instead of using remove in iterator, the List.remove method is not recognized by iterator. Therefore, the following requirements: The enhanced for loop process, the data cannot be deleted.
- Method Three: Use iterator. Iterator.hashnext, Iterator.next, Iterator.remove, because iterator at remove, has been positioned to delete the list element position, so the complexity of the delete operation is O (1), The time complexity of the entire implementation is O (N).
Listiterator
Listiterator added Hasprevious,previous,add,set method on the basis of iterator (Hasnext,next,remove).
Data structures and algorithms analyze tables, stacks, and queues