Learnitweb

What is the trade-off between using an unsorted array versus a sorted array ?

The tradeoff is in terms of speed. The major advantage of a sorted array is that to search an element in sorted array is faster. Sorted array has time complexity of O(log n), compared to that of an unsorted array, which is O (n).

The disadvantage of a sorted array is that the insertion operation has a time complexity of O(n). The insertion operation for an unsorted array takes constant time of O(1).

The time taken by sorted array in comparison to unsorted array is more because the element to be inserted must be moved to the right place in the array. And during this process elements must be moved to make room for the new element.