The question basically says it all. Suppose I have a (sorted) list that can contain anywhere from 1K to 1M items. I have a starting index and an ending index. If I use the ArrayList.sublist(start, end) method, is the time complexity O(n) or O(1)? I did check for answers here since I'd think would be a common question, but although I found a duplicate answer for a LinkedList, I couldn't find a specific question about ArrayList. Thanks to all for their answers!
What is the time complexity of Java's ArrayList.sublist(startIndex, endIndex) method?
7.2k Views Asked by Grace F. At
1
There are 1 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in ARRAYLIST
- Java catch the ball Game
- Arraylist and JTextArea Display issue
- sum of values of two lists in java
- Removing duplicates from arraylist using set
- Get the second same value in the ArrayList<String>
- Android: Add item to top of arraylist
- notifydataSetChanged working but only showing 1 result in listview Android
- How can I return an ArrayList from my AsyncTask?
- Any null safe alternative to ArrayList.addAll?
- String index out of bound exception in if statement
- Java convert ArrayList to int array
- Difference in performance of adding elements in Treeset directly vs transferring from arraylist?
- NumberFormat Exception Invalid int: "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" ArrayList
- What's wrong with my program - error message but works fine?
- how to remove duplicate objects from java arraylist
Related Questions in TIME-COMPLEXITY
- Time complexity of the algorithm?
- Shell Vs. Hibbard time complexity comparison
- Time complexity of swapping elements in a python list
- constant time complexity: O(x^c)
- Java TreeMap time complexity - lowerKey
- Complexity of LSD string sort (cfr. Algorithms by Sedgewick & Wayne)
- How to search a unknown composite key for dictionary in O(1) in c#
- Confusion about why NP is contained in PSPACE, EXPTIME etc
- Depth first search or backtrack recursion for finding all possible combination of letters in a crossword puzzle/boggle board?
- Time complexity of nested for loops
- TIme complexity of various nested for loops
- Best case performance of quicksort (tilde notation)
- Ranking a given list of integers in less than O(n^2)
- Bellman-Ford algorithm proof of correctness
- Division of very large numbers
Related Questions in SUBLIST
- To check if sublist exists in another list
- Sublists in a 2D List, Referencing
- Sublists of a list in java
- Set line items in custom sublist
- Java - Create sublist from a list based on suffix
- Tracing prolog code
- how to edit and update a filed in a sublist of a record in netsuite thought script?
- P3.5: Creating Sublist
- Split List<T> into Sublists<T> with LINQ
- Split a list into sub lists of decreasing size
- How to make one list split in half on the page
- Python - comparing sublists within two different lists
- Compare elements in two list and add different ones
- Delete Duplicated Sublists within a List in Mathematica
- Python: Remove Sublists from List if Same Including/Not Including Order
Related Questions in CONSTANT-TIME
- Why do we need to add a "sleep" method to make a constant time attack succeed?
- What thread safe java Data structure or custom implementation can let me get the position of a String in constant time
- Why does the hash() function in python take constant time to operate on strings of variable length?
- Cannot detect any meaningful timing difference in PHP (constant timing attack)
- Generic constant time compare function c++
- Algorithm to find numerical bucket in dynamic list
- What is the time complexity of Java's ArrayList.sublist(startIndex, endIndex) method?
- Create array structure in JavaScript that omits indexing
- Cartesian product in Gray code order : including affected set in this order?
- Constant-time string comparison function
- How to implement a generic PriorityQueue with basic methods in java?
- Is masking effective for thwarting side channel attacks?
- Compare two integers with bitwise operation
- How to access element(having a unique identifier) in a vector using a map in constant time?
- A java datastructure which has constant access time and allows duplicates
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The sub-list is backed by the source list. There is no copy step, so the time complexity is O(1).