Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views

Data Structures and Algorithms

Uploaded by

nitinraj3009
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Data Structures and Algorithms

Uploaded by

nitinraj3009
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Structures and Algorithms

give me the all time and space complexity of all the data structure and all searching , sorting
algorithm. in tabular form.

Here's a comprehensive table summarizing the time and space complexity of commonly used data
structures, searching algorithms, and sorting algorithms:

Data Structures

Data Structure Access Search Insertion Deletion Space Complexity

Array O(1) O(n) O(n) O(n) O(n)


Stack (Array-based) O(1) O(n) O(1) O(1) O(n)

Queue (Array-based) O(1) O(n) O(1) O(1) O(n)


Singly Linked List O(n) O(n) O(1) O(1) O(n)

Doubly Linked List O(n) O(n) O(1) O(1) O(n)


Hash Table N/A O(1) O(1) O(1) O(n)

Binary Search Tree O(log n) O(log n) O(log n) O(log n) O(n)

AVL Tree O(log n) O(log n) O(log n) O(log n) O(n)


B Tree O(log n) O(log n) O(log n) O(log n) O(n)

Heap (Binary Heap) O(n) O(log n) O(log n) O(log n) O(n)

Graph (Adj. Matrix) O(1) O(V) O(1) O(1) O(V²)

Graph (Adj. List) O(V+E) O(V+E) O(1) O(1) O(V + E)

Searching Algorithms

Algorithm Best Case Average Case Worst Case Space Complexity

Linear Search O(1) O(n) O(n) O(1)


Binary Search O(1) O(log n) O(log n) O(1)

Jump Search O(√n) O(√n) O(√n) O(1)

Exponential Search O(1) O(log n) O(log n) O(log n)

Fibonacci Search O(1) O(log n) O(log n) O(log n)

Sorting Algorithms

Algorithm Best Case Average Case Worst Case Space Complexity

Bubble Sort O(n) O(n²) O(n²) O(1)

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 1/2
Algorithm Best Case Average Case Worst Case Space Complexity

Selection Sort O(n²) O(n²) O(n²) O(1)

Insertion Sort O(n) O(n²) O(n²) O(1)


Merge Sort O(n log n) O(n log n) O(n log n) O(n)

Quick Sort O(n log n) O(n log n) O(n²) O(log n)

Heap Sort O(n log n) O(n log n) O(n log n) O(1)

Counting Sort O(n + k) O(n + k) O(n + k) O(k)

Radix Sort O(nk) O(nk) O(nk) O(n + k)


Bucket Sort O(n + k) O(n + k) O(n²) O(n)

Shell Sort O(n log n) O(n log² n) O(n log² n) O(1)

Let me know if you want further breakdowns or explanations of any specific algorithm or data structure!

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 2/2

You might also like