Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Draw diagrams of your implementation in order to gain a better insight as to how this is accomplished. implement a sorted linked list

Draw diagrams of your implementation in order to gain a better insight as to how this is accomplished.
   implement a sorted linked list
   analyze the code that we write

Part A: Drawings (15% of the mark)
Attached you will find a pdf files with diagrams of linked lists. Each diagram has a label indicating the operation to be performed to the linked list. The specification details of what each function does is listed in part B.
Read through the specs. Modify the list to show what the result of the operation is. Be clear about what is changing and how. The diagrams do not need to be neat.. but they need to be understandable. The idea is to think through what you need to change to achieve your goals.
Part B: Implementing a Sorted Linked list (35% of the marks)
The class declarations have been created in the a1.py starter file. The data member names are provided (but not initialized so code will not compile).
Aside from the class declaration you will find a function called iter
You are allowed to add data members to both Node and Linked list. You are also allowed to rename your data members BUT, if you do  this, you will need to alter the iter function to match your new data member names.
A sorted linked list is a linked list where values stay sorted from smallest to biggest. That is the smallest value is at the front of the list while the largest is in the back.
When a doubly linked sorted list is first created it is empty.
The sorted list has the following member functions

def insert(self,data)

this function inserts data into the list such that the list stays sorted. You may assume that the data being added can be compared using comparison operators

def remove(self,data)

this function finds and removes node containing data from the list. If a node containing data was found and removed, function returns True. If no such node was found (data was not in list), function returns False

def is_present(self,data)

This function returns true, if data is in the list, false otherwise

def __len__(self)  

This function returns the number of values stored in the list.
Write a  main program that initiates the sorted linked lists and uses the above methods so that you can test your code (Won't be marked)
Part C Analysis: (25% of the marks)
Perform an analysis of the 4 functions you wrote with respect to the number of nodes in your list. Find the O(f(n)) functions and give reasons for your results.

Step by Step Solution

3.39 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

When do you think a hiring decision will be made?

Answered: 1 week ago