140k views
2 votes
The searching algorithm of ordered array is faster than regular array, but the insertion time is slower than regular array. True or False?

User Kaveish
by
5.3k points

1 Answer

2 votes

Answer:

True

Step-by-step explanation:

In an ordered array or sorted array, we can implement binary search which uses branch prediction to search for values within the array. In binary search the array is divided into two halves. With the help of branch prediction we can easily find out in which part of the array the value may reside. Thus it drastically reduces the searching time. Whereas in a linear array, the array elements needs to be searched sequentially one after the other to match with the search element. Thus searching algorithm of ordered array is faster than regular array.

In a regular array, the insertion operation is faster than an ordered array because there we don’t have to decide the position at which the element needs to be inserted. In a regular array we can simply insert the new element to be added at the end of the array.

Thus the insertion time of an ordered array is slower than regular array.

User Alkasm
by
5.8k points