Ask questions about concepts, not about your exercise
Don't ask us about how to solve your homework exercise. Instead, spend some time trying to solve the homework exercise, and use that to figure out where you have a conceptual gap in your understanding.
Then, ask about the concept you don't quite understand yet.
If you've done a good job of this, often your question won't even mention your homework exercise at all. Yes, you'll start with your exercise, and you'll try to solve it, and you'll get stuck -- but then you should use that experience to try to generalize. Perhaps you might ask about how to solve a particular type of task (e.g., how do I prove a language is regular? how do I check whether an algorithm is correct?).
Make your question useful to others
A significant part of our mission is to build an archive of high-quality questions and answers that are likely to be helpful to others. Asking how to solve your specific homework exercise is unlikely to be useful to others (as they're unlikely to have the exact same exercise as you, or to be stuck at exactly the same point).
However, if you can ask a conceptual question that gets at a theme or type of task or conceptual confusion that many people studying the same material are likely to have, then it's more likely that your question will be useful to others.
But why can't I just post my homework exercise and ask for help?
The purpose of homework exercises are (1) to give you practice, and (2) to help you self-diagnose gaps in your understanding. Therefore, asking us to solve your homework question is almost never a good idea -- it doesn't serve either of those purposes, and is likely to waste your time and ours.
We're not a homework help site. Instead, we're here to get specific conceptual computer science questions answered, and to build an archive of knowledge. Make sure your question fits that purpose.
That said, if you can't figure out how to turn your problem into a broader conceptual question and want to ask about your exercise, here is the formula for what you must do:
Try to solve it before asking here. Spend a significant amount of time trying to solve it on your own, before posting here. Think hard for several hours. Try simplified versions of the problem to see if you can solve them. Try searching for similar problems here to see what you can learn from them. Don't post here until you've exhausted all available options.
Show your work so far. Tell us in the question what approaches you've tried and where you got stuck. Show us what progress you've made so far. Are you asking an algorithms question? Tell us what algorithm design paradigms you've tried (e.g., greedy, dynamic programming, divide-and-conquer, etc.), and where you got stuck with each one. Show us the best algorithm you were able to find so far, even if it's less efficient than you're looking for. This helps us write answers that are more likely to be useful to you, and helps us avoid wasting time trying something you already tried.
Ask about the specific concept that gives you trouble. We expect you to do the work of narrowing down the problem to the particular concept that's giving you trouble, and ask about that specifically. Don't just post your exercise and force us to infer what concept you're struggling with; you should do that part of the work, and then ask a question about the concept you're unclear on. This will yield a question that's more likely to be useful to others in the future. As a side effect, it shows that you're not just trying to get us to do your work for you.
Ask about a specific aspect of the problem that you're struggling with. If you can't figure out how to identify a concept that you're unclear on, articulate a specific question about some specific aspect of the exercise. For example:
BAD: "Here's my exercise, how do I solve it?"
GOOD: "I came up with the following algorithm and it seems to work on all examples of size $\le 5$, but I'm not sure how to prove it correct -- what are some techniques for that?"
BAD: "Here's my exercise, I just want a hint. Can anyone give me a hint?"
GOOD: "I came up with an algorithm for the exercise, but my instructor requires me to prove it terminates. What are some techniques for proving that an algorithm will terminate?"
GOOD: "I wrote a candidate proof of correctness. However, I'm not sure whether step 5 is valid: if $p$ is a shortest path from $s$ to $t$, can I assume that it doesn't contain any cycles?"
Credit the source. Reference the source of the exercise. If it's an exercise from a textbook, include the title and author of the book and the problem number, so that someone trying to answer the question can go look it up themselves if htey need to.
But my exercise isn't homework!
Actually, we don't care whether the exercise was assigned to you as homework or not. We may sometimes call your problem a "homework problem", but that is a shortcut. This policy applies whenever you ask an exercise-style problem (one designed to help you learn the material), regardless of whether it is part of a course or not, or whether it was assigned as homework, or if you're just trying it on your own.
Why won't you just show me the answer to the exercise? It's probably easy for you!
As explained on Math.SE:
Providing an answer that doesn't help a student learn is not in the student's own best interest, and if a solution complete enough to be copied verbatim and handed in is given immediately, it will encourage more people to use the site as a free homework service.
Or, as the adage says: "give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime". Giving someone the answer to their exercise is giving them a fish; it might seem helpful on first glance, but in the long run, it won't help them to understand the material or get better at solving similar problems. Many of us would prefer to focus on questions that will "feed you for a lifetime", e.g., by answering conceptual questions that will be useful beyond this one specific exercise.
Also, some or many of the experts here aren't very interested in devoting their energy towards a site whose primary purpose is to help with homework. If we answered homework questions, we'd risk being swamped by homework questions, and then some or many of the experts might leave, leading to a downward spiral for the site. We want to avoid that. Don't take it personally.
In general, as articulated on CS Theory, we want questions here to be inspired based on the spirit of knowledge sharing, not shirking. As they say there:
You should only post questions you're actually seriously thinking about. Users are expected to do their part and try to answer their question by themselves before posting them on cstheory and asking for help from others. Search to see if your question is already answered somewhere else (e.g. Wikipedia) before asking a question. Try to make your question interesting for others by providing some background knowledge. Remember, questions should be based on knowledge sharing, not on shirking. Shirking goes against the spirit of the site.
You might also enjoy reading the Open letter to students with homework problems on Programmers.SE.