The two numbered sentences you quoted would sound strange as they stand: you need to specify which particular walk you are talking about, and use a noun rather than a gerund, for example
How long does it take you to walk to work?"
You could re-organize this as:
How long does your walk to work take?
If the listener already knows which walk you are talking about, you could reduce this to:
How long does the walk take?
How long does it take?
Answers would be:
The walk takes half an hour.
It takes half an hour.
You can use a gerund walking in place of the noun walk, but you would use it differently.
How long does walking to work take?
If the listener knows what walk you are talking about, you would normally go directly to the fully ellipsized version:
How long does it take?
You would only keep the gerund and omit the other details if you needed to be specific about the mode of transport, for example to compare with cycling.
How long does walking take? = compared to cycling
Likewise, in a reply, you would be very unlikely to repeat the gerund, unless you need to be specific, for example, to contrast it with other modes of transport:
It takes half an hour
Walking takes half an hour: cycling takes ten minutes.
As Ronald Sole mentioned, you should not use a definite article with walking in this sentence.
Generally speaking, you don't use articles with gerunds. They are normally considered uncountable, so you never use a/an with a gerund. There are, however, exceptions but they are not well documented. There is some information about this in section 133 of the Oxford Guide to English Grammar (John Eastwood, 1994)
There are situations where we do use a definite article with a gerund, for example when talking about specific parts of something:
I found the swimming in the triathlon the hardest part.
I usually enjoy the walking part of my journey to work.
We use a definite article when a gerund is followed by of:
The playing of games is prohibited
We use a definite article when a gerund is considered countable, for example the set phrase
The comings and goings
When a gerund is used in a compound noun, the countable-ness is determined by the final word, so you cannot say
a hill walking
But you can say
a hill walking holiday
a walking holiday