- What is the disadvantage of array data structure?
- What is the importance of searching in data structure?
- Why linked list is better than array?
- Do you need to check whether there exists an element that is strictly greater than all?
What is the disadvantage of array data structure?
Disadvantages of array data structure:
Insertion and deletion operations are costly in arrays as elements are stored in contiguous memory. If the size of the declared array is more than the required size then, it can lead to memory wastage.
What is the importance of searching in data structure?
Searching in data structure refers to the process of finding location LOC of an element in a list. This is one of the important parts of many data structures algorithms, as one operation can be performed on an element if and only if we find it.
Why linked list is better than array?
Better use of Memory:
From a memory allocation point of view, linked lists are more efficient than arrays. Unlike arrays, the size for a linked list is not pre-defined, allowing the linked list to increase or decrease in size as the program runs.
Do you need to check whether there exists an element that is strictly greater than all?
You need to check that whether there exist a element which is strictly greater than all the elements on left of it and strictly smaller than all the elements on right of it. If it exists return 1 else return 0. NOTE: Do not consider the corner elements i.e A[0] and A[N-1] as the answer.