Data Structures and Algorithms Lab Journal - Lab 5 Doubly Linked List
Data Structures and Algorithms Lab Journal - Lab 5 Doubly Linked List
Data Structures and Algorithms Lab Journal - Lab 5 Doubly Linked List
Enrollment #: _________________________________
Class/Section: _________________________________
Objective
This lab session is aimed at introducing students to doubly linked list. In addition, the students
will also implement a number of utility functions involving doubly linked lists.
Task 1 :
c. Print the address of the node containing value 9 using the pointer ‘last’:
Node* temp=last;
while(temp->data!=9)
temp=temp->prev;
cout<<temp;
2
. Given the following linked list, state what does each of the following statements refer to?
first->data;
last->next;
first->next->prev;
first->next->next->data;
last->prev->data;
3
. Redraw the following list after the given instructions are executed:
cout<<ptr;// address of 17
cout<<ptr->next;// address of 20
cout<< ptr->next->prev;//address of 17
cout<<ptr->prev;//address of 15
ptr->next->prev = ptr->prev; // update prev of 20 which was
address //of 17 with address of 15
cout<<ptr->prev;//address of 15
cout<<ptr->prev->next;//address of 17
Task 2 :
Exercise 1
Implement the priority queue using doubly linked list. Provide the standard enqueue, dequeue
and traverse operations in the class.
Exercise 2
Implement the class Doubly Linked List to create a list of integers. You need to provide the
implementation of the member functions as described in the following.
class List
{
private:
Node * head;
public:
List();
~List();
// Checks if the list is empty or not
bool IsEmptyList();
InsertLast insertLast
deleteFirst deleteLast
Queue Stack
12345 54321
Exercise 3
Implement the Circular Queue using a doubly linked list. Provide EnqueueBeginning(),
EnqueueEnd(), DequeueBeginning(), DequeueEnd() and Traverse() functions in the class.
2. Exercise 2
3. Exercise 3
+++++++++++++++++++++++++