You are on page 1of 1

ASSIGNMENT 05

CS14950
Instructions:
1. This paper has 4 questions. Attempt all.
2. You must submit individual code files for every question. Your files should be
named as follow:
<Your_Roll_No.>_CS14950_<AsgnNo>_<Question_Number>.py
For example: 21PY124_CS14950_Asgn03_Q2a.py
3. You must submit the code file in the following link:
www.CS14950_A1.com
Topic: Linked List, pointers
# Declare a linked list as follows:
class Node(object):
# Doubly linked node
def __init__(self, data=None, next=None):
self.data = data
self.next = next
Question 01[10]**
Given a linked list find the median of all the elements of the list.
Input: [1, 2, 2, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 12, 12, 32, 52, 64, 75, 85, 95]*
Input will be a pointer to the root.
Output: 8
Question 02[10]**
Reverse a linked list.
Input: A pointer to the root
Output: No output, but you modify the linked list such that it stores the numbers in reverse.

*Input may not always be sorted


** You are not allowed to use library functions in this question.

You might also like