answersLogoWhite

0


Best Answer

You can, but it's not as straightforward as inserting or deleting from a list. This is simply because arrays are not intended for insertions or deletions other than at the end of the array. This is because an insertion requires that the entire array be reallocated (which may require the array to be copied in its entirety) simply in order to make room for the new element, which can then simply be inserted in the unused element at the end of the new array. To insert elsewhere in the array, all the elements following the insertion point need to be copied (for a second time) into the next element, starting with the last used element. the entire process can prove quite costly, especially if the elements are complex objects which would require their copy constructors to be invoked at least once and possibly twice. This is why it is generally better to use arrays of pointers to objects rather than arrays of objects, as copying a pointer is more efficient than copying an object. However, if your array undergoes frequent resizing in order to accommodate insertions and deletions, then you really would be better off using a list.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you perform insertion and deletion in an array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the various operations that can be performed on a queue?

In queue insertion takes place on rear end and deletion takes place on front end. INSERTION(QUEUE,N,FRONT,REAR,ITEM) :QUEUE is the name of a array on which we are implementing the queue having size N. view comlete ans at http://mcabcanotes.in/algorithm-to-perform-insertion-and-deletion-in-a-queue/


What is a double ended queue?

A double ended queue, or deque, is a queue in which you can access or modify both the head and the tail. The front pointer can be used for insertion (apart from its usual operation i.e. deletion) and rear pointer can be used for deletion (apart from its usual operation i.e. insertion)


What is the need of deque?

A double ended queue (or deque ) is a queue where insertion and deletion can be performed at both end that is front pointer can be used for insertion (apart from its usual operation i.e. deletion) and rear pointer can be used for deletion (apart from its usual operation i.e. insertion). So when we need to insert or delete at both end we need deque.


Write Algorithm to perform the insertion and deletion operation of a linear array?

//Algorithm to perform the insertion and deletion operation of a linear arrayINSERT (ArrA, n, i, item) where ArrA is a linear array with n elements and i is a positive integer where i <=n. The element 'item' will be inserted into the ith position in ArrA.1. j = n2. repeat steps 3 and 4 while j >= i3. ArrA[j+1] = ArrA[j]4. j = j - 15. ArrA[i] = item6. n = n+1DELETE (ArrA, n, i, item) where ArrA is a linear array with n elements and i is a positive integer where i <=n. The element 'item' will be deleted from the ith position in ArrA.1. item = ArrA[i]2. repeat for j = i to n -1 ArrA[j] = ArrA[j+1]4. n = n - 1NO HARD RETURNS ALLOWED


What do insertion and deletion have in common?

Both of them affect the length.

Related questions

Can linked list represent in array if yes show how insertion and deletions can perform in array representation of inked list?

yes


What are the various operations that can be performed on a queue?

In queue insertion takes place on rear end and deletion takes place on front end. INSERTION(QUEUE,N,FRONT,REAR,ITEM) :QUEUE is the name of a array on which we are implementing the queue having size N. view comlete ans at http://mcabcanotes.in/algorithm-to-perform-insertion-and-deletion-in-a-queue/


What is the difference betweens deletion and insertion?

Deletion is nothing but eliminating and insertion is adding.


Which is not a frameshift mutation substitution insertion deletion or point mutation?

frameshift- deletion and insertion point mutation- sustitution


Why you used link list in binary tree?

Linked list was introduced to reduce the space wastage done by array & also to make easier the insertion and deletion of elements from a list. A binary tree contains nodes of elements where insertion,deletion & searching is frequently done. So to make these operations easier linked list is used.


What do you understand by deque?

A double ended queue (or deque ) is a queue where insertion and deletion can be performed at both end that is front pointer can be used for insertion (apart from its usual operation i.e. deletion) and rear pointer can be used for deletion (apart from its usual operation i.e. insertion)


What are 3 types of mutations and what do they do?

The three different types of mutation are substitution, insertion, and deletion. They differ because deletion is missing a base, insertion has a base that was added, and substitution has a base that has been replaced.


What is a double ended queue?

A double ended queue, or deque, is a queue in which you can access or modify both the head and the tail. The front pointer can be used for insertion (apart from its usual operation i.e. deletion) and rear pointer can be used for deletion (apart from its usual operation i.e. insertion)


What is the need of deque?

A double ended queue (or deque ) is a queue where insertion and deletion can be performed at both end that is front pointer can be used for insertion (apart from its usual operation i.e. deletion) and rear pointer can be used for deletion (apart from its usual operation i.e. insertion). So when we need to insert or delete at both end we need deque.


What are 3 types of mutation?

Three types of gene mutations are substitution, insertion, and deletion. Another gene mutation would be frame shift. All these mutations can cause deformities of the gene.


What would produce a frameshift mutation?

An insertion/deletion event.


Which types of mutation can add genes to a chromosomes?

insertion and deletion