CORC 1312
HW #11: Limits of Computation


  1. Write an HTML page that uses a prompt to get an input number.The page should display "Ouch!" that many times. (So if the user enters 5, the page should display "Ouch!" 5 times on five separate lines.)

  2. Write an HTML page that uses a prompt ask the viewer for a phrase and then print the input phrase 10 times, each on a separate line. Number each phrase strating with the number 1. Iif the user enters "Hello World", the page should display "Hello World" 10 times.

  3. On the lab example entitled "complexity issues", you saw how long different types of loops took to complete. Look at the example that demonstrates different types of loops . Experiment with different input values. Which type of loop takes the longest? How many times can you tolerate a quadratic loop? How many times can you tolerate a factorial loop?

  4. Go to the Turing Machine web page and click on Machine 1 : unary addition. Unary addition is even simpler than binary addition. In the unary system a base 10 number is represented by that number of 1's so 3 is 111, 5 is 11111. To add two unary numbers together you just concatenate them 11 + 111 is 11111 (or in base 10 this would be 2+3=5). Step through the example that adds 11 and 1111111 (the two numbvers are separated by a blank space when the program is loaded). Click on the button 'step' to follow each action of the Turing Machine until the addition ios completed. What actually happened in order to get the correct result of the addition?

  5. Extra Credit: Write an HTML page that will get a value from the user and then will generate a dynamic HTML page that will contain a list of items corresponding to the number given. For example, if the user enters 3, the page should display: Use a loop to print the list. Before the loop print a <ul> tag, after the loop finishes print a </ul> tag. Inside the loop there will be one document.write statement that prints the <li> tag, the word Item followed by the number of the loop and the </li> tag. SInce the number of lines in the list can change each time the program is run, the loop will dynamically print the correct number each time.