Question
What will be the output of the following code when printList is called with a linked list containing the values 1 -> 2 -> 3? class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def append(self, data): new_node = Node(data) if not self.head: self.head = new_node return last_node = self.head while last_node.next: last_node = last_node.next last_node.next = new_node def printList(self): current = self.head while current: print(current.data, end=" -> ") current = current.next print("None") ll = LinkedList()
What will be the output of the following code when printList is called with a linked list containing the values 1 -> 2 -> 3? class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def append(self, data): new_node = Node(data) if not self.head: self.head = new_node return last_node = self.head while last_node.next: last_node = last_node.next last_node.next = new_node def printList(self): current = self.head while current: print(current.data, end=" -> ") current = current.next print("None") ll = LinkedList()
ll.append(1)
ll.append(2)
ll.append(3)
ll.printList()
More Basics of Computers Questions
- Size of MD5 message digest
- Which type of software is designed to help users perform specific tasks, such as creating documents, spreadsheets, or presentations?
- Which of the following sorting algorithms is NOT stable?
- What is one of the key advantages of using containers over virtual machines in modern application deployment?
- Which of the following statements accurately describes the role of cookies in web applications?
- The values appearing in given attributes of any tuple in the referencing relation must likewise occur in specified attributes of at least one tuple in the ...
- Abstract Class in Java
- What is a common security control used to protect sensitive data during transmission over the internet?
- Which protocol among the following is responsible for the remote management of network devices?
- What will be the output of the following JavaScript code when executed? let xhr = new XMLHttpRequest(); xhr.open("GET", "https://api.example.com/data", fal...
Relevant for Exams:
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)