0% found this document useful (0 votes)
13 views

Tutorial 4

The document discusses various concepts related to doubly linked lists: 1) It describes the initial configuration of a circular doubly linked list and asks to trace the output of swapping various next and prev pointers. 2) It asks how many next and prev pointers need to be updated for inserting/deleting a node at the beginning/middle of a doubly linked list. 3) It provides an incomplete function to insert a node after a given node in a doubly linked list and asks to complete it. 4) It asks to write an algorithm for converting infix to prefix notation and evaluate a given infix expression in prefix form. 5) It lists statements about doubly linked lists and asks which one

Uploaded by

Lone Survivor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Tutorial 4

The document discusses various concepts related to doubly linked lists: 1) It describes the initial configuration of a circular doubly linked list and asks to trace the output of swapping various next and prev pointers. 2) It asks how many next and prev pointers need to be updated for inserting/deleting a node at the beginning/middle of a doubly linked list. 3) It provides an incomplete function to insert a node after a given node in a doubly linked list and asks to complete it. 4) It asks to write an algorithm for converting infix to prefix notation and evaluate a given infix expression in prefix form. 5) It lists statements about doubly linked lists and asks which one

Uploaded by

Lone Survivor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Structure Lab, B.

Tech 2nd Semester

Tutorial 4

1. The following figure depicts the initial configuration of a circular doubly linked list where
the head is pointing to the first node.

What would be the output after executing the following sequence of steps -
i) head->next->next->next = head->prev
ii) head->prev->prev->prev = head->next->next->next->prev
iii) head->next->next->next->prev = head->prev->prev->prev
iv) printf(“%d” , head->prev->prev->prev->data)
2. If a doubly linked list is declared as

then
i) to inserting a node right most
ii) to deleting a node right most
iii) to insert a node in the middle of the list
iv) to deleting a node in the middle of the list
requires how many changes to various next and prev pointers ? Considering the doubly
linked list is not empty and length of more than equal to 2.
3. The following C function inserts a new element after a specific element ( a pointer is
given which points to that specific element after which the new element needs to be
inserted) in a doubly linked list.

struct Node { int data; struct


Node* next; struct Node*
prev;
};

void insertAfter(struct Node* previous, int value) { struct Node* element = (struct
Node*)malloc(sizeof(struct Node)); element->data = value; element->next = previous->next;
previous->next = element; element->prev = previous;

if (element->next != NULL){
______blank line________
}

}
Replace the blank line to complete the function ?

4. Write an algorithm for converting infix to prefix. And find what would be the Prefix
notation for the given equation?
K + L - M * N + ( O ^ P ) * W/U/V * T + Q

5. Which of the following is false about a doubly linked list? Justify your answer.
a) We can navigate in both the directions
b) It requires more space than a singly linked list
c) The insertion and deletion of a node take a bit longer
d) Implementing a doubly linked list is easier than singly linked list

You might also like