Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a function that takes the head of a doubly linked list and an integer Ind as arguments and deletes the node at index Ind.

image text in transcribed

image text in transcribed

image text in transcribed

Define a function that takes the head of a doubly linked list and an integer Ind as arguments and deletes the node at index Ind. The index starts from 1 . The program then prints the modified list. The definition of the linked list has already been given to you. Suppose the given linked list is 5>7>6 and Ind =1, then the modified list will be 76 klass Node: def__init_(self, data): self.data = data self.next = None self.tail=None class LinkedList: def__init_(self): self.head = None def push(self, new_data): new_node = Node (new_data) if self. head==None: self. head=new_node self.tail=new_node else : self.tail. next=new_node self.tail=new_node def deleteNode(self, Ind): \#write your code here def printlist(self): temp = self. head while (temp): print(temp.data, end =" ") temp = temp.next list = LinkedList () = int (input()) x= input () def push(self, new_data): new_node = Node ( new_data ) if self. head==None : self.head=new_node self.tail=new_node else : self,tail,next=new_node self.tail=new_node def deleteNode(self, Ind): \#write your code here def printlist(self): temp = self. head while (temp): print (temp.data, end =" ") temp = temp.next llist = LinkedList () n=int(input()) x= input () if n==len(xsplit()) : for i in x.split() : llist.push(int(i)) key = int(input()) llist.deleteNode(key) list.printList()

Step by Step Solution

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

=+a. Consumer-Focused show benefits.

Answered: 1 week ago

Question

How do books become world of wonder?

Answered: 1 week ago

Question

3. An overview of the key behaviors is presented.

Answered: 1 week ago

Question

2. The model is credible to the trainees.

Answered: 1 week ago