Data Structures

This page would mostly be covering the various data structures, their operation, properties and other algorithmic aspects of computation such as Sorting, Searching, Indexing etc.

The programs and code provided here would mostly be in C# or Java, Visitors are allowed to come-up with their own version in other language however I would request you to post your creation here for others to get the benefit of it.

What is an ADT?

Data structures are considered as ADT (Abstract Data Types) as their behavior and operations are known however the implementation is  hidden and one can come up with its own implementation or change\modify it for efficiency gain, better run time performance etc.

Describe run time complexities of most commonly used data structures ?

Pls refer to Complexity comparisons table below (Avg Case).

ADT Insertion Deletion Search
Array O(n) O(n) O(n)
Stack O(1) O(1) O(n)
Queue O(1) O(1) O(n)
LinkedList (At beginning) O(1) O(1) O(n)
LinkedList (At end) O(n)  O(n)
Binary Tree O(logn) O(logn) O(logn)
Binary Search Tree O(logn) O(logn) O(logn)
Hash Table O(1) O(1) O(1)

To access an element from an array usually takes the constant time if the index is known hence the run time complexity in that case is O(1).

 

Leave a comment