Write an algorithm to delete the person at location Dp without destroying the ex
ID: 668857 • Letter: W
Question
Write an algorithm to delete the person at location Dp without destroying the existing order of the list. The front of the list (base) is located at location “F.” The current last item in the list at location “L,” and the last available location is at location “M.” Other locations in the list are utilized for other purposes and should not be touched. You must detect and report underflow. On deletion, move all items above the deleted item down (towards F) to keep the list contiguous. Be sure to adjust L to properly reflect the number of people in the list. A sample deletion follows: I take off for “programs” written in any language rather than expressing the answer as an algorithm!
MyData: array(L0 .. M) of item;
MyData before of Joe :
Tom
Sam
Mary
Joe
Bob
1
2
3
4
5
6
7
8
L0
F
L
M
M+1
M+2
If the value of the pointer Dp is 4 (Sam) the resulting list will appear as shown below. Note the value in location 7 is physically in memory but not logically part of the list.
Tom
Mary
Joe
Bob
Bob
1
2
3
4
5
6
7
8
F
L
M
Tom
Sam
Mary
Joe
Bob
1
2
3
4
5
6
7
8
L0
F
L
M
M+1
M+2
Explanation / Answer
For Delete If you remove sam
Here F is First Position Considered tht will increase after delete dp SAM at 4th position
try this
if(F==0) then
underflow
else
item==array(F)
if(F==L)
set F=0
set R=0
else if (F==N) then
F=1
else
set front=front+1
print Array
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.