Question: Consider the following algorithm: Algorithm insertDbl ( list , dataIn ) This algorithm inserts data into a doubly linked list. Pre list is metadata structure

Consider the following algorithm:
Algorithm insertDbl (list, dataIn)
This algorithm inserts data into a doubly linked list.
Pre list is metadata structure to a valid list dataIn contains the data to be inserted
Post The data have been inserted in sequence
Return 0: failed--dynamic memory overflow
1: successful
2: failed--duplicate key presented
if (full list)
return 0
end if
set found to searchList (list, predecessor, successor, dataIn key)
if (not found)
allocate new node
move dataIn to new node
if (predecessor is null)
set new node back pointer to null
set new node fore pointer to list head
set list head to new node
else
set new node fore pointer to predecessor fore pointer
set new node back pointer to predecessor
end if
if (predecessor fore null)
set list rear to new node
else
set successor back to new node
end if
set predecessor fore to new node
return 1
end if
return 2
endinsertDbl
What does the condition "if (predecessor fore null)" test for?
Question 49Select one:
a.
insertion at end of list
b.
insertion in an empty list
c.
insertion at beginning of list
d.
insertion in a null list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!