Answer to Question #240670 in C++ for jan

Question #240670

Explain in your own words the Analysis of each Array list operation (add, remove and find)?


1
Expert's answer
2021-09-26T00:16:24-0400
Let there be an abstract structure Array list.From the methods of this structure, 
we can determine the number of elements and also find the first and last element.
Let's also assume that knowing the position of any element, we can determine the
position of the next and previous.


Then the add operation consists of the following steps:
   1.Get the position of the last elemenеt
   2. The last element is provided with information about the added element
   3. We set the added element as the last element
   4. Increasing the number of elements by one
For the operation of finding an element, perform the following steps:
   1. Get the position of the first element
   2. Compare it with the required value and end the search if it matches.
   3. Otherwise, if the element is the last, we constitute the fact that the
   element was not found.
   4. If the element is not the last one, we get the position of the next element and return to step 2
For the remove operation, we will carry out the following steps:
   1. Get the value of the last element
   2. Let's search for the element that needs to be removed
   3. Assign the found element to the value of the last element
   4. The penultimate element is the last
   5. Reduce the cout of elements by one

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS