Difference between revisions of "CSC231 Homework 5 2015"

From dftwiki3
Jump to: navigation, search
(Problem #2)
Line 56: Line 56:
 
: How does Javascript score, in terms of speed of execution, when performing arithmetic, compared to Java and Python, as illustrated in the [[Speed_of_Instructions:_Nasm,_Java,_C%2B%2B_and_Python_comparison| page on Nasm, Java, Python]] that we discussed in class?
 
: How does Javascript score, in terms of speed of execution, when performing arithmetic, compared to Java and Python, as illustrated in the [[Speed_of_Instructions:_Nasm,_Java,_C%2B%2B_and_Python_comparison| page on Nasm, Java, Python]] that we discussed in class?
 
<br />
 
<br />
: Write your answers in a text file.  Include supporting data in the file.  Submit it as a text file in the HW 5 PB 1 section on Moodle.
+
: Submit your answers as a pdf file called '''hw5_1.pdf'''.  Include supporting data in the file.  Submit it as a pdf file in the HW 5 PB 1 section on Moodle.
 
<br />
 
<br />
  

Revision as of 14:58, 28 October 2015

--D. Thiebaut (talk) 15:31, 21 October 2015 (EDT)


Page under construction!

UnderConstruction.jpg

Problem #1


  • Ssh to aurora.smith.edu using your 231a-xx account.
  • Go into your account's public_html directory.
  • Create a file with emacs, and call it javascriptTest.html.
  • Store the following code into it:


<html>
   <body>
   
      <script type="text/javascript">
         <!--
            var a = 33;
            var b = 10;
            var c = "Test";
            var i = 0;
            var linebreak = "<br />";

            document.write("sum_i=0^100 = ");
            sum = 0;
            for ( i=0; i<=100; i++ ) {
                sum = sum + i;
            }
            document.write( sum );
            document.write(linebreak);
         //-->
      </script>
      
      Example of Javascript arithmetic.
      <br />

   </body>
</html>


  • Make the file readable:
chmod a+r javascriptTest


CSC231JavascriptTest.png


Question
How does Javascript score, in terms of speed of execution, when performing arithmetic, compared to Java and Python, as illustrated in the page on Nasm, Java, Python that we discussed in class?


Submit your answers as a pdf file called hw5_1.pdf. Include supporting data in the file. Submit it as a pdf file in the HW 5 PB 1 section on Moodle.


Problem #2


This question is similar to Problem 1, but you have to measure the speed of java performing arithmetic with BigIntegers, as compared to performing arithmetic with ints.

Question
Is using BigIntegers slower, or faster than using ints, and how much faster or slower? Please include your supporting evidence in your answer. Submit a pdf of your answer called hw5_2.pdf in the HW 5 PB 2 section on Moodle.