MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Routine to delete element in an array implementation
A
for(i=pos-1;i<n-1;i++)list[i]=list[i-1];
B
for(i=pos-1;i<n-1;i++)list[i]=list[i*1];
C
for(i=pos-1;i<n-1;i++)list[i]=list[i+1];
D
for(i=pos-1;i<n-1;i++)list[i]=list[i+2];
Explanation: 

Detailed explanation-1: -If you want to remove an item from an array, you can use the pop() method to remove the last element or the shift() method to remove the first element. However, if the item you want to remove is not the first or last element, these methods are not the tools for the job.

Detailed explanation-2: -Deletion Operation Deletion refers to removing an existing element from the array and re-organizing all elements of an array.

Detailed explanation-3: -1 Answer. Easiest explanation-All the other elements will have to be moved, hence O(n).

There is 1 question to complete.