-3
  • a. Based on both CC formulas, explain why the number of procedural nodes does not influence CC.

    b. What would happen if you had multiple stop nodes?

    d. What is the effect on cyclomatic complexity of break, continue, goto and return statements?

    e. What is the effect on cyclomatic complexity of else or default clauses in if/switch statements?

    f. What is the effect on the cyclomatic complexity of a recursive method call?

    g. The total number of possible paths through a loop (for, while or do…while) is practically infinite because it can repeat any number of times. Why then does a loop only increase cyclomatic complexity by one?

    h. Does computational complexity (as expressed in big-O notation) affect cyclomatic complexity?

  • See this for asking homework questions: https://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions and this on how to write a good question: https://stackoverflow.com/help/how-to-ask . Right now you are just asking us to do your homework for you. – Dave S Jun 03 '17 at 19:14
  • **thanks for your advice** but I need answers for my questions. I had doutes about the Cyclomatic Complexity. – Asiri Harisandu Jun 03 '17 at 19:17
  • What work have you done so far? What specific things are you stuck on? What does your textbook and lecture notes tell you? – Dave S Jun 03 '17 at 19:24
  • I am stuck in the Cyclomatic Complexity Part **Would you like to help me with that?** – Asiri Harisandu Jun 03 '17 at 19:38
  • https://cs.stackexchange.com/questions/42044/difference-between-time-complexity-and-computational-complexity **FOUND THIS SOURCE LOOKS HELPFULL** – Asiri Harisandu Jun 03 '17 at 19:48

1 Answers1

3

Below given are my answers for your questions, You could correct if there is anything wrong with the given answers.

a. Based on both CC formulas, explain why the number of procedural nodes does not influence CC. CC is measure of number of linearly independent paths through the code. Procedural nodes can be combined together into one node hence there is only one single path through the code.no matter the number of procedural nodes cc =1. Since decision nodes d= 0 .

b. What would happen if you had multiple stop nodes?

CC measures linearly independent paths. Exit points don't ADD paths to the code, they TERMINATE paths, thus reducing CC (or in the very least, they certainly don't increase CC). https://stackoverflow.com/a/2073485/5156517

c. Say you use the V(G) = d + 1 formula, but instead of counting switch statements you count case clauses. Is this conceptually correct? Explain why you'll arrive at the right answer, even though a case clause is not a decision node.

Conceptually goes against the formula,3 cases means 3 decisions . the default path is not counted.

d. What is the effect on cyclomatic complexity of break, continue, goto and return statements?

No effect

e. What is the effect on cyclomatic complexity of else or default clauses in if/switch statements?

No effect, else and default clauses are not counted as decision nodes.

f. What is the effect on cyclomatic complexity of a recursive method call?

no. There is only one linearly independent path to the recursive method in your example, so it wouldn't increase the cyclomatic complexity.

g. The total number of possible paths through a loop (for, while or do…while) is practically infinite, because it can repeat any number of times. Why then does a loop only increase cyclomatic complexity by one?

Because it does not increase the number of linearly independent paths.,for while do loops does not imply multiple control paths..there for it does not add to cc.only one path is added when it goes back to the starting decion node after returning from the loop every time to check the condition, thus only one single path is added.

h. Does computational complexity (as expressed in big-O notation) affect cyclomatic complexity?

Computional complexity measure resources used up , space and time taken and not the measure of the complexity of the program.

Char
  • 123
  • 10
  • 1
    Thanks. This is really helpful – Asiri Harisandu Jun 13 '17 at 13:50
  • 1
    "An implicit default or fall-through branch, if specified by the language, must be taken into account when calculating complexity.".............I think "default" is taken into account . http://www.mccabe.com/pdf/mccabe-nist235r.pdf page 26 – User 101 Feb 12 '20 at 11:20