Question: a ) struct node { node * prev; int val; node * next; } ; struct Double _ Linked _ List { node * head;

a) struct node{ node*prev; int val; node*next;}; struct
Double_Linked_List{node* head; node*tall}; void
dll_method (Double_Linked_List* dll);
The dll_ method function has the following definition:
void dll_method (Double_Linked_List* dll){
node*left= dll->head;
node*right= dll->tail;
while(left != right && left-> prev!= right){
swap(left->val, right->val);
left=left->next;
right= right->prev;}}
i) What does the dll_method function do and how does the algorithm
work?
ii) Determine the runtime formula using dashes in the code. N is the
number of elements in the list. Count all assignments and compare and
consider a suitable number for the swap function.
iii) What is the complexity of the program in the best and worst case?

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 Databases Questions!