Question: Create a class LinkedList and add following functions. All function should run in O(n) Write a function Insert that takes two arguments x and j.

  1. Create a class LinkedList and add following functions. All function should run in O(n)
  1. Write a function Insert that takes two arguments x and j. Where x and j are integers. The function should insert value x at position j in the linked list.
  2. Write a function SearchByValue that takes an argument x. Where x is an integer. The function should search the position of the value x in the list and should return the position of the location. It should return -1 if the value is not found.
  3. Write a function DeleteDuplicates that deletes duplicate values from the linked list.The function should return a sorted list after deleting the duplicate values.

class Node:

def __init__(self,value):

self.value = value

self.next = None

class LinkedList:

def __init__(self):

self.head = None

self.tail = None

def Insert(self,x,j):

// your code goes here

def SearchByValue(self,x):

// your code goes here

def DeleteDuplicates(self):

// your code goes here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!