COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
In a array implementation of array, before insertion i have to move elements to one direction, then i have to free the position and then i have insert. which of the following code does that?
|
for(i = n-1 ; i >= pos-1 ; i ____ )list[i+1] = list[i];
|
|
for(i = n-1 ; i >= pos-1 ; i ____ )list[i-1] = list[i];
|
|
for(i = n-1 ; i >= pos-1 ; i ____ )list[i] = list[i+1];
|
|
for(i = n-1 ; i >= pos-1 ; i ____ )list[i] = list[i-1];
|
Explanation:
Detailed explanation-1: -Correct answer is C In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end. In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning.
Detailed explanation-2: -An array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number.
Detailed explanation-3: -What is the difference between building a linked list FORWARD and BACKWARDS? The head and tail are reversed definitions in the backward list.
There is 1 question to complete.