Question

Algorithms question: Please help if you can Find how many times the string “CS3130” will be...

Algorithms question: Please help if you can

  1. Find how many times the string “CS3130” will be printed in each of the following code fragments. Show all the details of calculations; your answer must be a function of n.

(a)

i=0

while i < 2n

      print “CS3130”

      i = i+2

     

(b)

i=0

while i < n

    for j = 0 to n

         print “CS3130”

    i = i+1

(c)

for i = 0 to n

    for j = 0 to i

         print “CS3130”

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Algorithms question: Please help if you can Find how many times the string “CS3130” will be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please DONOT attempt this Big O question if you don't know the exact answer. Algorithms question...

    Please DONOT attempt this Big O question if you don't know the exact answer. Algorithms question (Big O): Please explain me in details the order of growth (as a function of N) of the running times of each of the following code fragments: a)         int sum = 0; for (int n = N; n > 0; n /= 2)    for(int i = 0; i < n; i++)      sum++; b)         int sum = 0; for (int i =...

  • Hey, I really need help understanding the math get the answer that is given. Please help....

    Hey, I really need help understanding the math get the answer that is given. Please help. Thanks in advance. for (int k =0; k s Ign; k++) {for (int i =0; is n2; i++) Print “Hello World"; for (int j =0; j s n; j++) Print “Hello World"; } When n = 2, how many times will “Hello World” be printed?16 When n =4, how many times will “Hello World” be printed? 66 Assuming that the print is the basic...

  • Please answer both questions thank you. Question 52 (1 point) What is the output of the...

    Please answer both questions thank you. Question 52 (1 point) What is the output of the code snippet given below? String s = "abcde"; int i = 1; while (i < 5) { System.out.print(s.substring(i, i + 1)); i++; Question 50 (1 point) How many times will the output line be printed in the following code snippet? Please enter your answer as an integer. for (int i = 0; i < 3; i++) { for (int j = 1; j <...

  • Can I please get help with this question? Problem 3. How many lines, as a function...

    Can I please get help with this question? Problem 3. How many lines, as a function of n (in 0(.) form), does the following program print? Write a recurrence and solve it. You may assume n is a power of 2. function f(n) { If (n>1) { print.line ("still going");/ f(n/2); f(n/2); }

  • How many times does the message, “Hello” get printed out by the code segment below? int...

    How many times does the message, “Hello” get printed out by the code segment below? int count = 0; while (count < 41) {     printf(“Hello\n”);     count = count+3; } D Question 2 1 pts How many times does the message, "Hello" get printed out by the code segment below? int count = 0; while (count < 41) printf("Helloln"); count count+3;

  • hi show your solution in full details not just the final answer ,cheers mate can you...

    hi show your solution in full details not just the final answer ,cheers mate can you help please thanks I am stuck please Answer the following questions: Given the code segments below with n as the problem size, answer the following questions: //Code Segment 1 (Consider n as a power of 3) int sum = 0; for(int i = 1; i <= n; i = i*3)                sum++;                                    // statement1 //Code Segment 2: (Consider both possibilities for x) if(x...

  • Without using lambda in PYTHON How can I find the word "Code" and "code" on a website and print how many times they appear?

    Without using lambda in PYTHON How can I find the word "Code" and "code" on a website and print how many times they appear?

  • in my c++ class i need help with these question please Question 1. Indicate whether the...

    in my c++ class i need help with these question please Question 1. Indicate whether the first function of each of the following pairs has a smaller, same, or larger order of growth (to within a constant multiple) than the second function. Use the correct notation to indicate the order of growth (f(n) ∈O(g(n)), Ω(g(n)), or Θ(g(n)) as applicable). Prove your statement using limits. (a) (lnn)2 and lnn2 (b) 42n+1 and 42n Question 2. Use the formal definitions of O,...

  • Linux & C code help with creating a child process and kills itself with SIGNAL. I...

    Linux & C code help with creating a child process and kills itself with SIGNAL. I provided most of the code, I need some help to finish. Please provide output screen shot as well. Thank you! A Process creates a child process. Child process will print out "hello 0" "hello 1" ..... 1 line per second. After a certain number of seconds(user input), it kills itself WITH signal mechanism ONLY, don't use exit() on the child. You can use alarm()...

  • The following function is supposed to count how many times a certain base (represented as a...

    The following function is supposed to count how many times a certain base (represented as a character variable in Python) appears in a dna sequence (represented as a string variable in Python). Tried to execute it, but it does not work def count2(dna, base= [' 'c', ]) i = 0 for j in range(len(dna)): if dna[j] == base:    i += 1 return i dna = input('aaagggtttgct') print (i)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT