0% found this document useful (0 votes)
3 views2 pages

Java Time Complexity

This document provides a quick reference for Java time complexity across various data structures. It outlines the time complexities for operations on arrays, strings, HashMaps, linked lists, stacks, queues, priority queues, sorting algorithms, and balanced binary search trees. Each data structure's performance is summarized with average and worst-case scenarios where applicable.

Uploaded by

p8883749
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Time Complexity

This document provides a quick reference for Java time complexity across various data structures. It outlines the time complexities for operations on arrays, strings, HashMaps, linked lists, stacks, queues, priority queues, sorting algorithms, and balanced binary search trees. Each data structure's performance is summarized with average and worst-case scenarios where applicable.

Uploaded by

p8883749
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Time Complexity Quick Reference

Arrays

Access: O(1)

Search (unsorted): O(n)

Search (binary, sorted): O(log n)

Insert/Delete (middle): O(n)

Strings

Length: O(1)

Concatenation (+): O(n)

StringBuilder append: O(1) amortized

HashMap / HashSet

Insert/Search/Delete: O(1) average, O(n) worst

LinkedList

Insert/Delete at head/tail: O(1)

Search/Access by index: O(n)

Stack / Queue

Push / Pop / Enqueue / Dequeue: O(1)

PriorityQueue (Heap)

Insert: O(log n)

Remove min/max: O(log n)


Peek: O(1)

Sorting
QuickSort: O(n log n) average, O(n²) worst

MergeSort: O(n log n)

HeapSort: O(n log n)

InsertionSort: O(n²) average

Trees (Balanced BST like TreeMap)

Insert/Search/Delete: O(log n)

You might also like