Write a Program for Linked list manipulation.



Write a Program for Linked list manipulation...

Answer / Kuldeep Mittal

Here is an example of linked list manipulation in Python:nnclass Node:n def __init__(self, data):n self.data = datan self.next = Nonennclass LinkedList:n def __init__(self):n self.head = Nonenn def append(self, data):n if not self.head:n self.head = Node(data)n returnnn current = self.headn while current.next:n current = current.nextn new_node = Node(data)n new_node.next = self.headn self.head = new_node

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What are the 4 types of data?

1 Answers  


What does adt stands for?

1 Answers  


Does arraylist have a tostring?

1 Answers  


What is difference between array and arraylist? When will you use array over arraylist?

1 Answers  


What is data and its type?

1 Answers  


Which is faster hashmap or treemap?

1 Answers  


Is it legal to initialize list like this?

1 Answers  


When should structures be passed by values or by reference?

1 Answers   Tech Mahindra,


Why it is said that searching a node in a binary search tree is efficient than that of a simple binary tree?

1 Answers  


Which is the parent class of abstractqueue class?

1 Answers  


The element being searched for is not found in an array of 100 elements. What is the average number of comparisons needed in a sequential search to determine that the element is not there, if the elements are completely unordered?

11 Answers   Morgan Stanley, Wipro,


Define a relation?

1 Answers  


Categories