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
- Which layer in the OSI model corresponds to the Transport layer in the TCP/IP model and is responsible for end-to-end communication, error correction, and ...
- Which one of the following given statements possibly contains the error?
- Which CPU scheduling algorithm is considered optimal for minimizing the average waiting time in cases where process execution times are known in advance?
- Which of the following is NOT one of the OWASP Top 10 web security risks?
- Which of the following CPU scheduling algorithms is designed to minimize the average waiting time for processes?
- Which topology offers the highest fault tolerance and redundancy?
- What is one of the key advantages of using containers over virtual machines in modern application deployment?
- Which of the following testing types is best suited for verifying whether individual units of source code work as intended?
- Which of the following is the correct CIDR notation for a network with a subnet mask of 255.255.255.240?
- In a deadlock situation, which of the following conditions must hold true?
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)