You were correct with the pure.
As to the <*>, you've also started right with the Leaf f <*> t clause. Just go with it, by small steps. For example:
data Tree a = Branch (Tree a) (Tree a) | Leaf a deriving (Eq, Show)
instance Functor Tree where
fmap f (Leaf a) = Leaf (f a)
fmap f (Branch l r) = Branch (fmap f l) (fmap f r)
instance Applicative Tree where
pure x = Leaf x
--
Leaf f <*> t = f <$> t
t <*> Leaf a = ($ a) <$> …
Branch l r <*> t = Branch (… <*> t) (r <*> …)
You don't have to have a complete solution in your head before you write the code. Just start writing it, clause by clause, enumerating all the possibilities you could think of (meaning, structural possibilities for each of the arguments -- in this case, whether it's a leaf or a branch). You can always remove a redundant clause later.
The above definition of <*> works by recursion. And recursion works by assuming that we already have our definition for the the simpler cases, so we can build the result for a more complex case from solutions for its simpler sub-parts. Making sure that if the solutions for the sub-problems are correct -- and they are, by the assumption -- we combine those partial solutions properly so that the combined solution is correct for the whole problem:
recursion (problem) = solution where
problem has part1, part2, ...
sol1 = recursion(part1)
sol2 = recursion(part2)
....
solution is sol1, sol2, ..., combined properly together
And so in our case, when tree1 is Branch l r,
tree1 <*> tree2 =
case tree1 of Branch l r ->
let sol1 = l <*> tree2
sol2 = .....
in
combineTogether sol1 sol2
where
combineTogether subtree1 subtree2 = .....
Just finish it up and try it at the REPL. See that it works all by itself, through the magic of recursion, since we've also defined how to handle the simplest cases directly:
....
case tree1 of Leaf f ->
....
(treat the above as bits of pseudo-syntax).
Thus the last line of our proposed definition,
Branch l r <*> t = Branch (… <*> t) (r <*> …)
reads: all combinations of a tree which is Branch l r, with another tree t, is a new tree, which is Branch new_l new_r, where new_l holds all combinations of the .... with t, and the other one, new_r, holds the other combinations (just go ahead and make the most obvious substitutions for the dots there).
Just like with lists, where all combinations of [(1+),(2+)] with [30,40] is the list which combines all combinations of [(1+)] with [30,40], and all the combinations of [(2+)] with [30,40]:
[(1+),(2+)] <*> [30,40]
=
([(1+)] ++ [(2+)]) <*> [30,40]
=
([(1+)] <*> [30,40]) ++ ([(2+)] <*> [30,40])