Education News Weblog. Education News covers many courses in different fields of studies.Latest info not only in world of education but also the updates or exams, admissions and other details of many courses are provided. Some of the courses covered are Engineering, Technology, CFA, Advertising, Mass communication and many others are being added constantly.
On this page you'll find projects that will help you learn about computer programming and computer science. We've just launched this new area, and have started out with a set of programming projects based on JavaScript. We like it as a way to get started with programming because all you need is a Web browser and a text editor. You'll also find projects on file compression and a cool Geometry Applet that you can use to make interactive diagrams. We'll continue to add more Computer Science projects, so keep checking back! In the brackets are the difficulty levels of the projects which will help u to start.
The goal of this project is to write a JavaScript program that plays Tic-Tac-Toe. This project will take you through the steps of creating the interface for the game. You will need to take it from there and write the algorithms to create a computer opponent.
Introduction
This is an example of an intermediate programming project. You will be writing a program that allows you to play a game of Tic-Tac-Toe against the computer.
The Introduction will help you get started, in a step-by-step manner. If you follow the steps in the Introduction, you can gradually build up a webpage that you can use to play Tic-Tac-Toe with a friend. The experience you gain from building the two-player game will help you when you take on the challenge of programming the computer to play against you.
Here are the steps covered in the Introduction. First you will learn how to write an HTML file (webpage) that represents a Tic-Tac-Toe board. Next you will learn how to make your webpage respond to mouse clicks on the Tic-Tac-Toe board using JavaScript. Then you will learn how to update the text values of HTML elements on the fly. You will also learn how to program Tic-Tac-Toe knowledge into your program to detect when the game has been won or ended in a draw. At this point, you'll have a webpage that you can use to play Tic-Tac-Toe with a friend.
The challenge we leave you with for your project is to write the algorithms so that the computer can be your opponent instead. Can you create a computer opponent that always gives you opportunities to win? Can you improve that opponent so that it plays strongly but sometimes gives you an opportunity to win? Finally, we all know that it is possible to play a perfect game of Tic-Tac-Toe that results in a draw. Can you write an AI player that never loses?
The important HTML elements used in this project are:
SCRIPT
The element is used to begin and end a section of JavaScript code.
INPUT
The element can be used to create buttons. Buttons will represent the squares of our Tic-Tac-Toe board in this lesson.
P
The element is used to create paragraphs. We will use this element to create a space that tells the user what is going on in the game.
This element stands for "non-breaking space." It is used in HTML to place a space on the webpage where no line-break can occur. We will use non-breaking spaces to represent empty squares on the Tic-Tac-Toe board.
The important JavaScript objects, functions, and keywords used in this project are:
Var
The var keyword is used to declare a variable in JavaScript. A variable is a piece of data in JavaScript that can be changed and compared to other variables.
function
The function keyword is used to declare the beginning of a function. A function is a reusable piece of code that performs a specific purpose. In this project you will use functions to do things such as: place an X or an O on the game board, or check to see if someone has won the game, or to start a new game after one has finished.
== , !=
The operators "is equal to" (==) and "is not equal to" (!=) are used to compare values in JavaScript. There are also comparison operators for "less than" (<), "less than or equal to" (<=), "greater than" (>), and "greater than or equal to" (>=). The result of using a comparison operator is either true or false. Comparison operators are used in if statements and for loops to control program execution (see next two entries).
if...else
An if statement is a conditional statement. It is used to control the flow of the program using simple true/false expressions. For example, you might have a variable to indicate whose turn it is (X or O). When there is a mouse click on a blank square, you can use an if statement to check the value of the turn variable so you know whether to mark the square with an X or an O.
for
The for keyword is used to loop through a section of code a number of times. In this project we will use loops to check each value on the game board.
Making a JavaScript Tic-Tac-Toe Board
Laying out the game board. In this project, the game board is made up of buttons. There are 3 rows that each have 3 button across. Each button represents a square on the Tic-Tac-Toe board. The HTML code necessary to lay this out is easy. To do this, we use the HTML tag. The input tag must have a type. In our case the type is "BUTTON".
Notice that each input has an "ID" and a "VALUE." The VALUE is displayed on the face of the button. At the start of the game, the buttons are blank. The ID can be used to tell which button was pressed. We will also use the ID to change individual buttons to show an X or an O.
"Catching" mouse clicks. In order to make the Tic-Tac-Toe game interactive you will need to know when the user clicks on a button. JavaScript provides an easy way to do this. tags can have an ONCLICK attribute that you can use to call JavaScript code whenever the button is clicked. This must be added to each button on our board like so:
Now you will know whenever a player clicks on a button. The next step is putting the right value into the box. After that, we'll tackle alternative turns!
Setting the value of a square. The first step in making the Tic-Tac-Toe game work is setting the value of a square when it is clicked. Each of the squares will work in the same way. Because the click response is common to all of the squares, you should write one piece of code that can be used by any square when it is clicked. To do this you need to create a JavaScript function. At the top of your HTML file (in the section) add a tag so you can write JavaScript code, like this:
Now you can write JavaScript code inside the script section. Let's start by creating the function we will call whenever a button is clicked:
function squareclicked(square) // squareclicked is a function that is called whenever a button is clicked. { }
These four lines create a function that will do nothing. The first line is a comment. It summarizes what the function does. The function is named "squareclicked," and it has one argument, "square." The argument will be used to tell the function which button has been clicked. This means you need to update your buttons to call the squareclicked() function:
Notice how "this" is being sent whenever we call the squareclicked() function. When you put "this" inside an onclick attribute it represents the that the onclick attribute is created in. This means that whenever a button is clicked it will call the squareclicked() function and pass itself to the function. This will enable you to set the value of the square. Now update the squareclicked() function to set the value of the button:
function squareclicked(square) // squareclicked is a function that is called whenever a button is clicked. { square.value = 'X'; }
Jackpot! Now whenever a button is clicked it gets the value 'X'. The next step is to put the right value in the square based on whose turn it is.
Alternating turns. In order to alternate turns and place the right value in the square that is clicked we will need to keep track of whose turn it is. You can do this by creating a "global" variable (a global variable can be accessed from any function) in the JavaScript section outside of the squareclicked() function, like this:
The goal of this project is to investigate the effects of timing interval and step size on perceived animation smoothness. You will write a simple JavaScript program that will move an object around on a Web page. This project will help you create more advanced Web pages that could have any type of animation.
Introduction
This is an example of a first-time programming project. You will be writing a basic animation program that will move an object around on your computer screen, on a Web page in your browser window. The project uses JavaScript, an interpreted programming language supported by most Web browsers. You will learn how to write an HTML file containing your program, and how to load and run the file in your browser. You'll also learn how to control the motion of the object, and you will experiment with different settings to see the effect on apparent smoothness of the motion.
Preliminaries
These are things you need to know before you get started.
You'll need to write your file with a text editor, which is a program that can save plain text files. The "Notepad" program that comes with Windows will do just fine. You should not use a word processing program (e.g., Word), because word processors do not save files as plain text by default.
JavaScript is a programming language for web pages, so the HTML file you will be writing is like a simple web page. Here is the basic format of an HTML file:
[Title and JavaScript functions go here.]
[The parts you want to appear on the page go here.]
HTML uses tags to designate various parts of the document. Tags are enclosed by the characters "<" (less-than sign) and ">" (greater-than sign). The first line is a comment, enclosed by "". Comments in an HTML file are ignored by the browser, so you can use them as notes to yourself. They can help you remember what the different parts of your program are supposed to do. You need the tag "" at the beginning. The document has two sections, a HEAD section, which contains general information about the document, and a BODY section which contains the displayed material. The HEAD section is where you would specify the title of the document, and also where you would put JavaScript functions used in the document. The end of the HEAD section is indicated by the end tag, "". Next comes the BODY section, with material that you wish to appear on the page. It is ended by the end tag "". Finally, the end of the document is indicated by the HTML end tag, "". The same pattern applies to all HTML tags: the end tag is made by adding "/" (the forward slash character) to the beginning of the corresponding start tag.
For practice, try using your text editor to write a very simple HTML file like the one below. (You can write it yourself, or you can copy and paste from your browser to your text editor.)
Hello, world!
Use your text editor to save the file. Call it something like "HelloWorld.html" (when choosing a name for your file, always end the name with ".htm" or ".html").
Now open your HelloWorld.html file with your browser. In your browser, use the "File" menu, and choose the option "Open..." (for Firefox, choose "Open File..."). Using the controls in the File Open dialog box that pops up, navigate to your file and select it. You should see "Hello, world!" on both the browser title bar and on the body of the page.
Getting Started with JavaScript
Now that you've succeeded with writing an HTML file and opening it with your browser, you're ready to delve into JavaScript. The following link has a step-by-step tutorial that will give you a great introduction to JavaScript programming: http://www.webteacher.com/javascript/index.html
Writing a JavaScript Animation
The rest of the Introduction will cover the pieces that you need to write an animation program in JavaScript:
a function, to control the timing and placement of the image on the page,
one or more HTML image objects to move on the page,
a JavaScript object (that is, a way to refer to the HTML object(s) in JavaScript), and
a timer, to update the page at regular intervals.
Once you have put all these together, you will be able to start exploring how changing the settings affects the appearance of the animation.
A JavaScript Function
As you learned in the tutorial, JavaScript uses functions. Functions can do nearly anything you want them to do. Your function will contain code that will run your animation. A function in JavaScript looks like this: // This is an example of a single-line JavaScript comment. // Below is an example of a multi-line JavaScript comment. /* This function doesn't do anything useful yet, but we will add code later to make it work.
function myFunction() { /* Your animation code will go here */ }
Here is how to put the JavaScript function into an HTML file. The function is included in the section of the HTML file, like this: My Page
An HTML Image Object
Your function will need an object to animate. For this example, we will keep it simple. We will use a ball as an object. To get your object, right click on the red ball (below), and do a "Save As..." Save the ball image as ball1.gif, in the same directory as your HTML file. (Note: if you choose a different filename, you will also have to change the name in the HTML tag, below.) Here is the ball image for you to save:
Now we will add the ball to your HTML file by inserting the following text just after :
Save your HTML file and open it in the Web browser. You should see the little red ball on your Web page. The ball should be 10 pixels wide. It should be located 200 pixels from the top of the Web page and 200 pixels from the left edge of the page. You can try changing the way your ball looks by changing the value of left, top, width, and height. For example, if you want a bigger ball, you can change the width and height from 10 to 50. Prove to yourself that it works. Try changing some of these values, saving the HTML file, and opening the file in a browser.
An Object in JavaScript
The object from step 2 is an HTML image object. We need to be able to use this object in JavaScript, so we have to create a JavaScript variable to represent the ball. Add this variable on the line before myFunction.
var myBall;
The statement above creates the variable, next we have to assign a value to the variable. That is, we have to tell JavaScript that myBall should represent the HTML object "ball." To do this, we use a built-in JavaScript object called document. We can use document to get an HTML object by its ID. To do this, replace the last line you added with:
var myBall = document.getElementById("ball");
This line tells JavaScript to look in the HTML document and find the object, or element, with the ID "ball," and assign it to the JavaScript variable myBall. You will notice in the HTML our ball has the ID of "ball." Now JavaScript knows about the ball in the Web page.
The Time
Animation requires that we change something on an interval. For example, we may want to change the position of the ball every five seconds, or change the color every ten seconds. We will tell JavaScript to call our function, on an interval so we can change something. To accomplish this add the following call to the built-in JavaScript method, "setInterval" (add this line before the code for myFunction()):
setInterval("myFunction()", 200);
This line tells JavaScript to run myFunction every 200 milliseconds. Right now, myFunction does not do anything. So let's add animation code to myFunction.
Writing a Simple Animation Function in JavaScript
For the first animation example, we will have the ball keep moving down the screen. First we need another variable to keep track of our current location. Add this variable after the myBall variable:
var loc = 200;
Add this code between the braces of myFunction:
loc += 10; // This adds 10 to the value of loc myBall.style.top= loc; // This moves the ball
In this case we are changing one of the properties of the ball. The property is style.top. We can change this property to make the ball move up or down.
Now save your HTML file, and open it in your Web browser. You should see your ball keep moving down the screen. You have just created an animated Web page! If your page is not working, here is the entire HTML file: My Page
Improving the Animation Function: A Bouncing Ball
Just having a ball move down of you Web page may not be very exciting. We can make the ball move up and down by using a variable to determine the direction the ball is moving. Once it reaches an upper limit or a lower limit, we will make it turn around. Add the variable direction to the line above myFunction:
var direction = 0;
We will use this variable called direction so we know which way the ball is moving. 0 means the ball is moving down, and 1 means the ball is moving up. Try replacing myFunction with this new myFunction (to keep your previous work, save the HTML file with a new name):
function myFunction() { if(0 == direction) { /* move down */ loc += 10;
if(loc >= 500) { /* reached lower limit, change direction */ direction = 1; } } else { /* move up */ loc -= 10;
if(loc < direction =" 0;" top =" loc;">
Going Further
The goal of this project is to determine the best settings for the timer interval and ball step size in order to produce the smoothest animation. You can make the project even better by going further with your investigation of animation. The Variations section, below, has some suggestions to get you thinking.
Note for JavaScript files with Internet Explorer: If you experience difficulty running your JavaScript code in Internet Explorer, we strongly suggest that you install the Firefox web browser and use it instead of Internet Explorer. For more information or to download the Firefox installer, see: http://www.mozilla.com/firefox/.
Terms, Concepts and Questions to Start Background Research
To write a simple program in JavaScript, you should do research that enables you to understand the following terms and concepts:
HTML concepts:
start tags and end tags,
comments,
the section,
the section,
the section,
the tag.
JavaScript concepts:
functions,
variables,
objects.
specific JavaScript functions:
setInterval()
general programming concepts:
reserved words,
control statements (e.g., if...else).
Questions:
How do you use a variable to make an HTML object accessible within a JavaScript function?
How do you set a timer to call a JavaScript function at some regular interval?
How would you make it easy to change the step size (distance the ball moves with each timer tick) and timer interval for your animation?
What is the frame rate for displaying movies on a screen? How does this relate to your timer interval?
Bibliography
You can find a step-by-step JavaScript tutorial at the link below. After studying the tutorial, you should be able to answer all of the questions listed above, and you'll be ready to write a simple calculator. http://www.webteacher.com/javascript/index.html
A list of reserved words in JavaScript (you cannot use these words for function or variable names in your program, because they are reserved for the programming language itself): http://www.javascriptkit.com/jsref/reserved.shtml
If you get interested and start doing a lot of programming, you may want to try using a text editor that is a little more sophisticated than Notepad. An editor designed for programming can help with formatting, so that your code is more readable, but still produce plain text files. This type of editor can also do "syntax highlighting" (e.g., automatic color-coding of HTML) which can help you to find errors. Here is a free programmer's editor that you can try: http://www.crimsoneditor.com/
Materials and Equipment
To do this experiment you will need the following materials and equipment:
computer with Web browser (e.g., Internet Explorer, Firefox),
text editing program (e.g., Notepad),
stopwatch or timer (one that is accurate to seconds will work OK).
Experimental Procedure
Adding Variables
The goal of this project is to determine the best settings for the timer interval and ball step size in order to produce the smoothest animation. The script you created in the Introduction section has hard-coded numbers for these quantities. It will be much more convenient to change these values if you add variables for the timer interval and the step size for the motion of the ball. This way, you will only need to change the value in one place, when the variable is assigned a value, rather than searching for a hard-coded value in multiple places throughout the script.
It will be much more convenient to change these values if you add variables for the timer interval and the step size to control the motion of the ball.
You can make it even easier to change the values of the variables by adding a section to your HTML page, with fields linked to the script variables. With this feature, you'll be able to change the values right in your Web browser program, rather than having to use a text editor to change the HTML file. It's not hard to do, and you can learn all about it by checking out this project: Forms and Functions: Writing a Simple Calculator Program with JavaScript.
Calculating Time
The next thing to do is to verify that your timer interval is working as you expect. For instance, there may be some timer settings that are too fast for your browser program to keep up with. For each of the timing intervals you wish to use in your experiment, you need to run a test like the one described below.
As our example, we will use the final animation function presented in the Introduction. This is the one where the ball changes direction, bouncing up and down from 0 to 500 pixels.
When you start the Web page, the ball will be moving down. At the moment the ball turns around and starts moving up, start your stopwatch. Stop it at the moment the ball reaches the top of the Web page. How long did it take?
Now let's do some math to determine how long it should have taken. We set the interval to 200 milliseconds. On each interval we said to move the ball 10 pixels. That means the ball should move 50 pixels every second. How did we determine this?
Now we know the speed of the ball. How long should it take for the ball to move from the bottom to the top (500 pixels)?
How close were the timed results to your calculated results? (For a timer interval of 200 ms and a distance of 500 pixels, they should agree pretty well.)
For each timer interval that you wish to use for your experiment, run a similar test. For shorter timer intervals, you will need to also decrease the step size (or increase the total distance traveled, or count more than one "bounce") in order to have enough time elapse so that you can measure it accurately.
Measuring Smoothness
You'll need to figure out a rating scale to measure "smoothness." Start out by making observations at different settings:
Do you see multiple images or a single image of the ball?
Does the ball appear clearly, or is it fuzzy? (Maybe a little bit of blur makes the animation more realistic?)
Is the motion really jumpy?
Once you have an idea of the range of effects, assign a rating scale from 1 to 5, low scores being poor ratings and high scores being excellent ratings.
If you have some willing helpers available, ask them for their perceptions. Explain your rating scale and have them rate the smoothness with the same settings you try (see below).
Collecting and Analyzing Your Data
Systematically explore combinations of timer interval and step size in order to find the best settings for your animation. (Remember to verify that the desired timer settings actually work as you expect.)
For example, you could try a series of step sizes that increase by a factor of 2: 1, 2, 4, 8, 16, 32 pixels, etc.
You can do a similar series of timer steps.
Try each possible pair of settings, and rate the smoothness of the animation.
Make graphs of your smoothness rating as a function of step size and timer interval.
Which combinations work best? Is there more than one group of settings that works reasonably well?
Variations
You could try animation by changing any of myBall's properties like you changed myBall.style.top. For example:
myBall.style.left: You can move the ball from left to right.
myBall.style.width: You can make the ball bigger, or smaller.
myBall.src: This may be the most interesting. You can actually change the picture. Just be sure to put all the image files in the same directory as the HTML page.
Can you think of how to make the ball look like a real bouncing ball? Like the one on the left?
How about making it even more realistic, and have it lose some height with each bounce, and eventually stop?
For a multiple image animation, you could try animating a stick figure. From your ball animation you may have an idea how much an arm or leg should move with each time step, and what the time interval should be. Try it and see if the motion looks realistic!
For a fairly advanced animation, how about two stick figures bouncing the ball back and forth between them?
Another idea would be to try to relate your findings to the human visual system. What is the typical frame rate for displaying movies on a screen? How does this relate to the best timer intervals for your animation? Can you think of ways to measure visual response times? Persistence of vision? Computer monitor response times?
Objective The goal of this project is to compare how long it takes to perform various mathematical operations with different variable types.
Introduction Computer technology keeps advancing at an amazing pace. Today's home computers have more memory, run faster and are relatively less expensive than computers from ten or even five years ago. Is there a way to measure how fast your computer is? You might think that you could tell simply from the processor clock frequency, but this doesn't tell the whole story. The clock frequency just tells how many operations per second the CPU can perform. In modern multi-tasking operating systems, the CPU's time is split between many programs running at once. Also, the central processor (CPU) sends data to and receives data from other subsystems on the computer (e.g., memory, disk drives, video display) which usually run at slower speeds. Modern processors are equipped with high-speed data buffers (called caches) to alleviate these bottlenecks. There are also many strategies for optimizing the order of operations in a program for greatest efficiency.
In this project you will use a Java applet (see Experimental Procedure, below) to measure how long it takes for the computer to perform arithmetic operations (addition, subtraction, multiplication and division) with various data types (integers, long integers, floating point numbers and double-precision floating point numbers).
Measuring how long an operation takes provides useful information, both for optimizing algorithm performance, and also as a "benchmark" comparison between two computers. However, you must keep in mind that with today's multi-tasking operating systems, measuring the execution time of any single process is difficult. The operating system splits CPU time between all of the programs that are running. No program has "exclusive" access to the CPU. Generally, CPU processing speed is fast enough so that you don't notice this because programs appear to be instantly responsive. Behind the scenes though, each program is getting a slice of CPU time, then waiting for its next turn before it can run again.
So it is important to remember that, due to multi-tasking, the processing times you measure with the applet below will not represent the actual CPU time required to perform an addition or subtraction. In order for the applet to give you a best estimate, keep the number of open applications to a minimum, and make sure that any open applications are not performing tasks that require lots of CPU time (e.g., printing files or downloading content from the Internet).
How the Timing Applet Works The applet works by repeating the arithmetic operations within two nested loops. In the inner loop, the program steps through an array (of the chosen data type: int, long, float or double) of 10,000 elements. The chosen operation (addition, subtraction, multiplication or division) is performed by pairing array elements: one counter (index "j", in the code snippet below) starts at the beginning of the array and counts up, the other (index "k" in the code snippet below) starts at the end of the array and counts down. Thus, the inner loop performs the chosen operation 10,000 times. The outer loop (index "i" in the code snippet below) counts how many times the inner loop should be executed. The default choice is 10,000 times, which means that the arithmetic operation will be performed 10,0000 × 10,000 or 108 times. The time it takes to execute these two nested loops is measured by the two calls to the Date().getTime() method, which returns the time with millisecond resolution. By subtracting startTime from endTime, the program determines how many milliseconds it took to execute the two nested loops. Again, it is important to remember that the operating system does not give the applet exclusive access to the CPU. The total time measured will also include some time that the operating system allocated to other programs while the applet was running. This is unavoidable, but do your best to minimize the number of other programs running.
startTime = new Date().getTime(); for(int i = 0; i < j =" 0," k =" nElements" endtime =" new">
The applet is written in the Java programming language, which includes four different "primitive" data types for representing numbers: int, long, float and double. The "int" data type uses 32 bits to represent an integer, while the "long" data type uses 64 bits. So the "long" type can represent numbers with larger magnitude than the "int" type, but at the cost of taking up twice as much space, and perhaps taking longer time to process at the CPU. (You'll find out when you make your measurements.) Similarly, the "float" type is a 32-bit decimal number, while the "double" type is a 64-bit decimal number. Which data type do you predict will be processed most quickly? Which do you predict will be processed most slowly? The two non-arithmetic operations, "no op" and "assign", can be used to calculate the loop "overhead" (the time the program spends incrementing and decrementing the loop variables, and assigning the result to the output array). In the "no op" case, there is an empty statement (literally no operation) in the inner loop. In the "assign" case, a constant value is copied to each member of the output array. The controls of the applet are self-explanatory (including pop-up "tool tips" that display when the mouse hovers over a control). The "Run" button executes the currently chosen operation. Be careful not to set the number of iterations too high, or you'll be waiting a long time for it to finish. Rememeber that this is the count for the outer loop, and that the actual number of operations performed will be 10,000× this number (since there are 10,000 array elements to cycle through for each iteration of the outer loop). The text box will show a report of all of the tests you've run. It will display the operation performed, the total number of operations (outer loop count × inner loop count), the total time this took (in milliseconds, abbreviation: ms) and the time per operation (in nanoseconds, abbreviation: ns). The time per operation is calculated by dividing the total time by the number of operations.
Terms, Concepts and Questions to Start Background Research To do this project, you should do research that enables you to understand the following terms and concepts:
bit
numerical data types: int, long, float, double
two's complement notation (for representing positive and negative integers)
multi-tasking
CPU frequency
CPU clock period
Questions What is the lowest number that can be represented in 32 bits using twos complement notation? In 64 bits? What is the highest number that can be represented in 32 bits using two complement notation? In 64 bits? What is the clock period for a processor that runs at 2.4 GHz?
computer with Java-enabled web browser and Internet access
calculator or spreadsheet program for analyzing results
Experimental Procedure
First do your background research and make sure that you understand the terms and concepts and can answer the questions above.
Use the applet below to measure the execution time for each of the operations for integers.
Run the applet at least 10 times for each operation.
You can use the keyboard to copy and paste the results from the applet to a spreadsheet program for analysis. Click on the output text area. Type +a to select all of the contents. Type +c to copy the contents to system clipboard. Finally, switch to your spreadsheet application and paste from the clipboard.
As mentioned in the Introduction, the "no op" operation does nothing within the loop, so it provides a measure of the loop overhead. The "assign" operation simply copies a constant value to the output array (no calculation is performed). These two operations provide a control conditions. Both should take less time than any of the other operations. The time for the "int assign" operation can be subtracted from the time to complete the arithmetic operations for integers.
Use a calculator or spreadsheet program to calculate the average time for each operation.
Repeat your measurements and analysis (steps 1–6) for each of the four data types (int, long, float and double). You will want to measure the "assign" time separately for each data type.
How do your predictions about processing time compare with the actual results? Were you surprised? If so, can you think of an explanation for what is going on? Can you think of another experiment you might try to test your explanation?
Variations
Try running the applet on different computers whose processor type and speed you know and compare the results. Keep conditions as similar as possible (e.g., minimize the number of additional programs running). How do the times compare vs. speed within the same processor type? How do the times compare across processor types?
Do your results change if you have other programs running while you make measurements with the applet? Does it matter if they are actually doing something or not?
Here's an idea for analyzing your data further: how many clock cycles does each operation take? If you know the "speed" of your processor (in MHz or GHz), you can calculate this by multiplying the time per operation (in seconds) by the processor frequency (in hertz).
For a more advanced project, use JavaScript to write your own program to investigate execution time for a function call or writing data to the screen. For example: how long does it take to generate a random number using Math.rand()? How does this compare with calculating the sine of an angle using Math.sin()? How does this compare to simple arithmetic operations in JavaScript? Can you estimate how many arithmetic operations are performed to generate a random number? How long does it take to write a line of text to the screen? How does this compare with changing the background color?
For an even more advanced project, use a C or C++ compiler to write a native timing program. Java is an interpreted programming language, so it is likely that your native compiled C program will run faster than the Java applet. Is this the case?
Objective In this experiment you will investigate the relationship between the amount of information stored on a CD-R disc and the size of the "burn" by measuring with a ruler. Introduction The music that we listen to, the movies we watch, and the video games we play are often stored on CDs. A CD is a way of storing data, or information, by using a laser to etch the data into a long groove, called a track. The data in the track is etched as a long series of tiny bumps that are scanned by a laser in your CD or DVD player. Each CD has one long spiral track of data that circles from the inside of the disc to the outer edges. Each tiny data track is only about 0.5 microns wide, with a spacing of 1.6 microns between each track. A micron is a millionth of a meter, so each individual track is much too small to be seen by the naked eye!
A CD has a long, spiraled data track. If you were to unwind this track, it would extend out 3.5 miles (5 km). (Harris, 2006)
If you have a CD burner, you can store data by using special CDs called CD-Recordable discs, or CD-R's. These special discs don't have any bumps in the data track. Instead they use a series of light and dark spots which are "burned" into the track when the laser of the CD burner shines on the track and reacts with a special light-sensitive dye inside the disc. When the disc is empty the dye is clear, but when you heat the dye with concentrated light from the laser, the dye darkens. By blinking the laser on and off along the track, the CD burner etches a series of light and dark spots which create a digital pattern that a standard CD player can read. In this experiment you will take advantage of the change in the light-sensitive dye inside the CD-R to measure how much data has been burned. After marking the border between used and unused parts of the disc, you will use a ruler to measure how much space the data uses. What will happen to the amount of free disc space as more data is burned to a disc?
Terms, Concepts and Questions to Start Background Research To do this type of experiment you should know what the following terms mean. Have an adult help you search the Internet, or take you to your local library to find out more!
Compact Disc - Recordable (CD-R)
CD burner
data
file size (MB)
Questions How much information can be stored on a CD? Can you see the information stored on a CD? How can the amount of information on a CD be measured?
a photo, music file, or folder about 100 MB in size
permanent marker
metric ruler
Experimental Procedure
In this experiment you will need to use a CD burner to write data onto a CD-R disc. First, check with a parent to make sure you have access to a CD burner. It can either be internal (inside your computer) or external (something you will need to connect with a cable). Have your parents show you how to properly use the device.
CD-burners use software to help you burn data onto the disc. Familiarize yourself with the software that your parents use to burn CDs. Make sure you know how to: load files onto the blank CD, find the allocated (used) disc space, find the available (unused) disc space, initiate and complete the burn.
You will need some data to burn onto your CD. Good sources of data are photos and music. Try to find a file that is about 100MB. It is a good idea to save a separate copy of this file, because you will be writing on your CD later (and probably spoiling it for reading on your computer). So be sure that the file you choose is either unimportant or is saved somewhere on the computer else.
Once you find the file you want to use, put it in a new folder on your desktop entitled, "CD Burn Experiment" so that you can find it easily.
Next, you need to make a data table to record your results
Place your first CD-R into the burner, place one copy of your file on the disc and burn. Write down the amount of used and unused disc space in your data table.
After the burn is complete, write "Trial #1" on the front of the CD with a permanent marker.
Turn the CD-R over to the shiny side. While tilting the CD-R from side to side, try and locate a fine line that encircles the disc. The inner side of the line will appear slightly dull compared to the outer side of the line. This line is at the edge of the laser etched portion of the data you have written on the disc, which appears dull.
When you see it, place a dot on the line with a permanent marker. Measure the distance from the center of the CD-R to the dot you have marked. Write the data in your data table.
Repeat steps 6–9 with the next CD-R, but this time put two copies of your file on the disc (which should be about 200 MB). When complete, label the disc "Trial #2" and find the line, mark and measure as before.
Continue to add one more file each time, until you have a total of 6 or seven trials. This will depend upon the size of the file you use (<> 100 MB) and the size of your CD-R (74 or 80 min).
What happens to the location of the line as more data is stored onto the disc?
Make a graph of your results. Does the distance from the center of the disc increase or decrease as more data is added? Is the amount of increase in distance the same each time? Why or why not?
Variations There are many other variables you can test with CD-R and data storage. How does the speed of the burn change as the amount of data increases? Try using different brands of CD-R discs, do they all use the same amount of measured disc space for the same amount of data? For a more advanced measurement you can use geometry to calculate the area of used and unused disc space for each trial. The area of a circle is πr2 and the radius (r) is one half of the diameter. To calculate the area of used disc space, you need to subtract the area of the inner circle (the hole at the center of the CD-R) from the area of the outer circle (where you marked the edge of the used disc space). To calculate the unused disc space, subtract the area of the used disc space plus the area of the hole from the area of the entire CD-R. How do these results compare to the previous results? How do these results compare to the measurments from the CD burning software? Is this way of seeing the data more or less consistent? For other projects about data, information and file sizes see How Many Letters?
Objective In this experiment you will test the use of wildcards to maximize the number of results from a search. Introduction Wildcards are special characters that are used during a search to find all of the possible variations of a word or search term. A search term can have a wildcard character (*) in any position that is normally a letter. The (*) will act as a substitute for any number of letters and can be used in any position of a word, either at the end or in the middle of the word. For example: win* win, wins, winter, window, windows, etc. win*w window
You can use wildcards as a strategy to retrieve better information when searching for something on the Internet. In this experiment you will search for a topic using the Yahooligans search engine. By using wildcards in different places, you can test whether using a wildcard will get better results from your search.
Terms, Concepts and Questions to Start Background Research To do this type of experiment you should know what the following terms mean. Have an adult help you search the Internet, or take you to your local library to find out more!
wildcard
search term
search engine
algorithm
Questions How do search engines work? What search terms give the best results? How can using wildcards get you better results for a search term?
Bibliography Yahooligans is a search engine just for kids that you will use for this experiment: Yahoo, 2006. "Yahooligans: the Web Guide for Kids." [accessed: 3/10/06] http://yahooligans.yahoo.com/ Here is an excellent tutorial for kids on conducting Internet searches, so take a search lesson from Kids Click: Kuntz, J., 1999. "Kids Click! Worlds of Web Searching," Ramapo Catskill Library System. [accessed: 3/10/06] http://www.rcls.org/wows/ This is a search site built by librarians just for kids. Conduct an Internet search, browse through the different categories, or take a search lesson: Kids Click, 2005. "Web Search for Kids by Librarians," University of California, Berkeley. [accessed: 3/10/06] http://sunsite.berkeley.edu/KidsClick!/ Google is the number one search engine these days. Learn the Google Search basics by reading through this tutorial: Google Help Center, 2006. "The Essentials of Google Search," Google. [accessed: 3/10/06] http://www.google.com/help/basics.html
Materials and Equipment
computer with Internet connection
notebook and pencil
graph paper
printer
Experimental Procedure
You will be using the Yahooligans search site for this experiment, so familiarize yourself with the site before you begin.
Decide on a topic to do your search. Choose something that is specific and that has multiple spellings, like biology (bio, bio sci, biology, biologist, biologists, biological, biological science, biological sciences, biotechnology, etc.).
Choose your search terms and write them in the table. Choose terms with and without wildcards (bio, bio*, biol, biol*, biolog*, biology, etc).
Type each term into the search box of Yahooligans, and click "search" to get your results.
Write the number of "Category Matches" and "Web Site Matches" into your data table.
Continue for each search term you can think of. Do as many different combinations of terms and wildcards that you can think of.
Make two graphs of your data: one for the "Category Matches," and one for the "Web Site Matches." The best type of graph is a bar graph. Draw a scale on the left side of the graph (Y-axis) that represents the number of results. Draw a bar labeled with each search term up to the number of matches.
What was the effect of the wildcard, did it retrieve fewer matches or more matches? Was it better to use the complete spelling of a specific word, or to use a wildcard for retrieving more matches? Do the same strategies work for "Category Matches" and "Web Site Matches," or should you use different strategies? Did you get unexpected or irrelevant results for any of your terms?
Variations
Yahooligans is one site for searching for information, but there are many other databases where wildcards can be useful for finding information. One place where wildcards can be useful if for searching through the computer catalog at the library. Try this experiment at your local library to test the use of wildcards for finding books, magazine and articles on a topic of interest.
Google is a very popular search engine that uses automatic wildcards. That means Google adds a wildcard to your search term without your even knowing so it can find more search results for you. Investigate how Google automatically assigns wildcards to your search term. Are the results ranked higher or lower than your original term? Try misspelling a term on purpose. How does the Google algorithm fix the problem?
Try this experiment with other search engines like Alta Vista, Lycos, Dog Pile, or Web Crawler. Do you get the same results for different search terms with each one? What does this reveal about how search engines are programmed? Do you think the different search engines use the same or different algorithm?
I am a IT engineering student from K J Somaiya College (Mumbai,India).I like blogging about engineering, education, exams, environment and world updates .