Tree edges are those edges which appear in the final DFS forest. For example in case of connected graph (i.e. resulting DFS forest containing only one tree), if we run DFS over it, edges belonging to the resulting DFS tree are called tree edges.
Let us assume the graph has $x$ number of connected (or strongly connected in case of a directed graph) components. And assume 1st component has $K_1$ tree edges, 2nd component has $K_2$ tree edges and xth component has $K_x$ tree edges.
Such that $K_1 + K_2 + K_3 + \ldots + K_x = K $ ( = total)
Or in other way we can imagine like, the final DFS forest has $x$ trees and those trees are having $K_1$ , $K_2$ , $K_3, \ldots, K_x$ edges respectively.
Now we know that a tree having $K_x$ edges contains $K_x + 1$ nodes. Similarly a tree having $K_1$ edges contains $K_1 + 1$ nodes, etc. and so on.
So, summation of nodes in each tree $= n$
$(K_1 + 1) + (K_2 + 1) + (K_3 + 1) + \ldots+ (K_x + 1) = n \\ \ \ \ \ \implies (K_1+K_2+K_3+\ldots+K_x) + x = n \\ \ \ \ \ \implies x = n - K$
Correct Answer: $D$