Given a linked list. Print all the elements of the linked list.
Note :- End of Line is handled by driver code itself. You just have to end with a single space.
Example 1:
Input:
N=2
LinkedList={1 , 2}
Output:
1 2
Explanation:
The linked list contains two 
elements 1 and 2.The elements 
are printed in a single line.
Example 2:
Input:
N = 3
Linked List = { 49, 10, 30}
Output: 
49 10 30
Explanation:
The linked list contains 3 
elements 49, 10 and 30. The 
elements are printed in a single 
line.
Your task:
You don't need to read input or print anything. Your task is to complete the function display() which takes the head of the linked list as input and prints the linked list in a single line.
 
Expected Time Complexity : O(N)
Expected Auxiliary Space : O(1)
 
Constraints :
1 <= N <= 100

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: #Your task is to complete this function

#Your function should print the data in one line only

#You need not to print new line



'''

class node:

    def __init__(self):

        self.data = None

        self.next = None

'''

class Solution:

    def display(self,node):

        #code here

Solutions:
class Solution:

	def display(self, node):
		temp = node
		while temp:
			print(temp.data, end=' ')
			temp = temp.next


class Solution:

	def display(self, node):
		while node != None:
			print(node.data, end=' ')
			node = node.next


class Solution:

	def display(self, node):
		curr = node
		while curr:
			print(curr.data, end=' ')
			curr = curr.next


class Solution:

	def display(self, node):
		temp = node
		while temp is not None:
			print(temp.data, end=' ')
			temp = temp.next


class Solution:

	def display(self, node):
		a = node
		while a:
			print(a.data, end=' ')
			a = a.next


class Solution:

	def display(self, node):
		dummy = node
		while dummy:
			print(dummy.data, end=' ')
			dummy = dummy.next


class Solution:

	def display(self, node):
		while node:
			tmp = node.data
			node = node.next
			print(tmp, end=' ')


class Solution:

	def display(self, head):
		while head != None:
			print(head.data, end=' ')
			head = head.next


class Solution:

	def display(self, node):
		node
		if node == None:
			return
		else:
			print(node.data, end=' ')
			self.display(node.next)


class Solution:

	def display(self, node):
		current = node
		while current:
			print(current.data, end=' ')
			current = current.next


class Solution:

	def display(self, node):
		itr = node
		while itr:
			print(itr.data, end=' ')
			itr = itr.next


class Solution:

	def display(self, node):
		elements = []
		if node.data != None:
			elements.append(node.data)
			while node.next != None:
				elements.append(node.next.data)
				node = node.next
		print(' '.join((str(element) for element in elements)), end=' ')


class Solution:

	def display(self, head):
		self.head = head
		temp = self.head
		while temp:
			print(temp.data, end=' ')
			temp = temp.next


class Solution:

	def display(self, node):
		temp = node
		l = []
		if temp is None:
			return
		else:
			while temp.next is not None:
				print(temp.data, end=' ')
				temp = temp.next
			if temp.next is None:
				print(temp.data, end=' ')


class Solution:

	def display(self, node):
		for i in range(len(values)):
			print(values[i], end=' ')


class Solution:

	def display(self, node):
		l = []
		while node != None:
			l.append(node.data)
			node = node.next
		for i in l:
			print(i, end=' ')


class Solution:

	def display(self, node):
		ptr = node
		while ptr:
			print(ptr.data, end=' ')
			ptr = ptr.next


class Solution:

	def display(self, node):
		head = node
		while head is not None:
			print(head.data, end=' ')
			head = head.next
		return head


class node:

	def __init__(self):
		self.data = None
		self.next = None

class Solution:

	def display(self, node):
		current = node
		while current is not None:
			print(current.data, end=' ')
			current = current.next


class Solution:

	def display(self, node):
		if node is None:
			return None
		while node:
			print(node.data, end=' ')
			node = node.next