How will you reverse Linked List.



How will you reverse Linked List...

Answer / Sapna Rai

Here is an example of reversing a singly linked list 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

Define non linear data structure.

1 Answers  


in tree construction which is the suitable efficient data structure? (Array, linked list, stack, queue)

1 Answers  


What is the difference between data types and data structures?

1 Answers  


List out few of the Application of tree data-structure?

1 Answers  


What are the Difference between tcp and udp?

1 Answers  


When will you sort an array of pointers to list elements, rather than sorting the elements themselves?

5 Answers  


How do you determine if a binary tree is height balanced?

1 Answers  


What is the complexity of arraylist?

1 Answers  


What are the issues that hamper the efficiency in sorting a file?

1 Answers  


Is json a data structure?

1 Answers  


Run time memory allocation is known as ?

1 Answers  


Explain extended binary tree.

1 Answers  


Categories