You are on page 1of 1

Birla Institute of Technology and Science-Pilani, Hyderabad Campus

First Semester 2019-2020


Lab Sheet-1
Course No CS G526 Course Title: Advanced Algorithm and Complexity
Date: 7/8/19

General Instructions: Argue logically. Write it in a manner that explains your logic very
clearly. Do not miss steps in between.
Task 1 Implement a singly linked list in C/C++. Implement the following operations

1. Compute the Length of a Linked List. It also can print the linked list given an appropriate flag.

2. Insert a node at the beginning of the list.

3. Insert a node at the end of the list.

4. Insert a node in the middle of the list given its position. If p is the position parameter then the
inserted node will be the p th node in the list after insertion. Thus if p = 1 then a new node will
be inserted in the beginning. If p exceeds the length of the list then it will be inserted at the end
of the list with a warning about p exceeding the length of the list.

5. Delete a node from the beginning of the list

6. Delete a node from the end of the list

7. Delete a node from the middle of the list. If p is the position then the p th node from the current
list will be reduced by 1.

Task 2 Find nth node from the end of a singly Linked List. Implement it in a manner that you can do
it in one pass.
Task 3 Given a singly linked list, reverse the linked list.

You might also like