human
Print all k | utility function to print contents of a vector from index i to it 's end .
Binary Tree Node.
This function prints all paths that have sum k.
empty node.
add current node to the path.
check if there 's any k sum path   in the left sub-tree. .
check if there 's any k sum path   in the right sub-tree. .
check if there 's any k sum path that   terminates at this node   Traverse the entire path as   there can be negative elements too .
If path sum is k , print the path.
Remove the current element from the path.
A wrapper over printKPathUtil ( ).
Driver Code"
Solution in Python:
assistant
#Here is code to print all k and the other steps required.
 def printVector ( v , i ) :
	for j in range ( i , len ( v ) ) :
		print ( v [ j ] , end = " ▁ " )
	print ( )
class newNode :
	def __init__ ( self , key ) :
		self . data = key
		self . left = None
		self . right = None
def printKPathUtil ( root , path , k ) :
	if ( not root ) :
		return
	path . append ( root . data )
	printKPathUtil ( root . left , path , k )
	printKPathUtil ( root . right , path , k )
	f = 0
	for j in range ( len ( path ) - 1 , - 1 , - 1 ) :
		f += path [ j ]
		if ( f == k ) :
			printVector ( path , j )
	path . pop ( - 1 )
def printKPath ( root , k ) :
	path = [ ]
	printKPathUtil ( root , path , k )
if __name__ == ' _ _ main _ _ ' :
	root = newNode ( 1 )
	root . left = newNode ( 3 )
	root . left . left = newNode ( 2 )
	root . left . right = newNode ( 1 )
	root . left . right . left = newNode ( 1 )
	root . right = newNode ( - 1 )
	root . right . left = newNode ( 4 )
	root . right . left . left = newNode ( 1 )
	root . right . left . right = newNode ( 2 )
	root . right . right = newNode ( 5 )
	root . right . right . right = newNode ( 2 )
	k = 5
	printKPath ( root , k )