Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 days ago.
Improve this question
Marry and John are happy couple. They usually go on long drive on the weekend.
But today is Marry's birthday and John wants to make it special for her. He wants to again take her on a "special walk" as a birthday gift.
The city in which they lives is represented as an unweighted directed graph with N nodes and M edges. A "special walk" in the graph starting at node u is a simple path that begins and ends at the same node u.
Formally, A special walk is path u , a1 , a2 , a3 ,..., ai ,.... , u where ai are distinct and not equal to u for all i.
Now since John is really nervous about taking his girl out, he needs your help. For every node in the given graph, tell whether it is possible for John to take his girl on a "special walk" starting at that node.
please provide me code for this problem
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I was given a question where two graphs are given and the questions asks if the two graphs are the same and whether the problem was a P, NP, NP-hard or NP-complete. By looking at the two graph, the graphs are not the same. However, I don't know what type of problem it is.
First of all, you have to define what you mean by "the same". There are several ways of defining equality, but the most likely one in this context is graph isomorphism, where two graphs are equal if there is an edge-preserving bijection between them.
Next, if the problem is just to decide if your two given graphs are the same or not (and this is how you stated it), the problem is trivially in O(1) (and therefore in P and NP).
If, however, the problem is to decide whether any two graphs are isomorphic, the problem is in NP. It is currently neither known whether it is in P nor whether it is NP-complete.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Alright, so one of my friends challenged me to get this done, but I just can't get very far....
What he asked me to do is to make a program that shows and counts ALL the possible parts of an entered number.
Example for 5:
1+1+1+1+1
2+1+1+1
3+1+1
4+1
5
3+2
2+2+1
I would like the program to be written in either C++ or some pseudocode, I wouldn't mind for either.
Anticipated thanks to you all!
Edit: Not duplicate. I requested a solution in c++; and the other one is in Python. Also, my question asks for ALL possible parts that added return the initial number.
For non zero partitions ( imagine boolean separators in array of 1)
2 ** (n-1)
This list would include both 2 + 3 and 3 + 2.
If you allow 0 then infinite.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have an input text
inputQ <- "What can I do ..my baby has rash all over. Suggest good rash cream"
I have a list of terms
terms <- c("diaper","cloth diaper","rash pants","rash","baby wipes","rash cream")
I wish to exact match one of the terms and return it as well
I tried using for loop, but is there a better method
Result should be
rash cream
stored in matchedTerm
You can try to get all the matches, then check for the one with the biggest number of characters:
wh_match <- names(unlist(sapply(terms, grep, inputQ)))
wh_match[which.max(nchar(wh_match))]
# [1] "rash cream"
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have for example 4 points: A (latitute1, longitude1), B (latitute2, longitude2), C (latitute3, longitude3), D (latitute4, longitude4).
If I am a driver and I go from point A, I need an algorithm that calculates the most efficient way for me to visit all the points B, C, D starting from A. So that the distance is the smallest possible.
The algorithm should tell me the most effective order: A --> C --> B --> D (for example).
What matters is the total distance traveled is the lowest possible.
Thanks so much!!! :)
Maybe look into Dijkstras algorithm?
https://en.m.wikipedia.org/wiki/Dijkstra%27s_algorithm
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i would like to graph this kind of equation, z=x*y. I would like to set intervals like -n< x <-n and so on, to see how z varies in function of x and y at the same time. I also need to check the value of z at given x and y and see where z is at its maximum, for example. Thanks and have all a nice day!
Edit: the equation i am trying to study is z=x * (164+0.25y)
where 0 < x < 2.5 and 0 < x < 700.
P.S. I don't understand the downvotes, I kindly asked for a question in a polite way, providing as many details as I could.
This question may be a little outside of the scope of this site, but in regards to a graphing program:
One of the easiest ways to determine things about graphs is to use Wolfram Alpha a computational knowledge engine. A quick tour on the site and just trying a few things out should get you to where you want to go pretty quickly.
Since you appear new to this site, check out some of the Stack Overflow Basics and be sure to up-vote any help you get or questions you may find helpful.