archive-edu.com » EDU » H » HWS.EDU

Total: 727

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • CS100 Fall 1997: Test #2
    five wheels like this Answer Note For part a you have to remember how circles are drawn Assuming that R is a positive number then the command circle R draws a circle of radius R that sticks out on the left side of the current turtle position To draw the rim of the wheel you need to move the turtle to a position on the rim and orient the turtle so that it faces in the correct direction Here are possible answers to this problem a The wheel drawing subroutine SUB wheel radius Draw a 6 spoke wheel of the given radius The wheel will be centered on the current turtle position and at the end of the subroutine the turtle will be back at its original position and orientation This subroutine assumes that the turtle is originally facing to the right DECLARE ct ct 0 for counting the number of spokes LOOP Draw the spokes forward radius back radius turn 60 ct ct 1 EXIT if ct 6 END LOOP The turtle has turned 360 degrees so it is again facing to the right PenUp move 0 radius Move to a position at the bottom of the wheel PenDown circle radius Draw the rim PenUp move 0 radius Move back to the center END SUB b The program to draw five wheels using a loop DECLARE ct for counting the number of wheels ct 0 LOOP wheel 3 Draw a wheel of radius 3 PenUp forward 8 Move to center of next wheel PenDown ct ct 1 EXIT IF ct 5 END LOOP Question 6 Carefully describe the picture produced by the following program You can t actually draw the picture since it is in color but you might want to draw a black and white version DECLARE x ct ct 0 LOOP x randomInt 3 rgb random random random turn 45 forward x turn 90 forward x turn 45 ct ct 1 EXIT IF ct 10 END LOOP Answer Each execution of the loop produces a peak shaped like an upside down V The color of each peak will be chosen at random The height of the line will be one of three sizes chosen at random There will be 10 of these peaks lined up in a horizontal row each one attached to the next Here is a sample in color Question 7 Answer the following questions assuming that the subroutine guess has been defined as SUB guess num len declare ct ct 0 LOOP forward len back len ct ct 1 EXIT IF ct num turn 90 PenUp forward 1 PenDown turn 90 END LOOP END SUB a Draw the figure produced by guess 1 10 b Draw the figure produced by guess 3 5 c Draw the figure produced by guess 5 2 turn 120 guess 5 2 turn 120 guess 5 2 Answer The subroutine call statement guess ct len will produce a set of ct parallel lines The length of each line will

    Original URL path: http://math.hws.edu/TMCM/f97/test2.html (2016-02-07)
    Open archived version from archive


  • CS100 Fall 1997: Quiz #1
    language is a very specific technical term that refers exclusively to a programming language It does not refer to any old language used by a machine In particular ASCII code which is used to represent textual data is not an example of machine language Question 2 What is a byte Answer A byte is an eight bit binary number That is it is a string of eight bits each of which can be 0 or 1 Question 3 What is the purpose of a computer s main memory What is the structure of main memory that is how is it organized Answer The main memory or RAM of a computer holds programs and data that are directly accessible to the CPU The CPU fetches program instructions from memory and carries them out Main memory is organized as a numbered list of locations Each location holds a binary number with some fixed number of bits In most modern computers each computer holds one byte and the size of main memory is usually measured in bytes Question 4 Computation can be defined as the mechanical manipulation of symbols Explain what this means Answer A symbol is something that has no meaning in

    Original URL path: http://math.hws.edu/TMCM/f97/quiz1.html (2016-02-07)
    Open archived version from archive

  • CS100 Fall 1997: Quiz #2
    3 11 2 7 111 2 11 1011 2 4 100 2 8 1000 2 12 1100 2 Question 2 Draw the logic circuit that corresponds to the boolean expression A and not B or C or B and not C Answer Question 3 In the following circuits label the output of every gate to show whether it is ON or OFF Answer The labels that have to be added are shown in red Question 4 Define the term ALU Answer The ALU Arithmetic Logic Circuit is the part of the CPU that performs the basic arithmetic and logical operations on binary numbers It can perform a variety of operations such as addition subtraction left shift etc The ALU has control wires that tell it which operation to perform Question 5 Sometimes we categorize input wires to a circuit as either data inputs or control wires From the point of view of a human what is the difference between data inputs and control wires What is the difference from the point of view of the circuit Answer Many circuits are meant to perform operations on data that is provided as input to the circuit Data inputs provide the data to be manipulated in the form of a binary number encoded by turning the data input wires ON to represent a 1 or OFF to represent a 0 A control wire is used to control the operation of the circuit For example it might tell the circuit which of several operations to perform on the data An example of this would be the control wires of an ALU Alternatively turning a control wire on and off might make the circuit perform some action An example of this would be the Load Data wire of a memory circuit which tells the circuit

    Original URL path: http://math.hws.edu/TMCM/f97/quiz2.html (2016-02-07)
    Open archived version from archive

  • CS100 Fall 1997: Quiz #3
    the input to that gate the result is a circuit that repeatedly turns itself on and off such a circuit can be used a kind of clock Feedback loops are used mainly in memory circuits See the illustrations in xLogicCircuits Lab 2 for examples Question 3 Explain what is meant by the fetch and execute cycle and give some examples of the kind of small individual steps that can occur as part of a single fetch and execute cycle Answer The fetch and execute cycle is the process by which the CPU executes machine language programs that are stored in main memory The CPU reads or fetches one instruction from memory and then carries out or executes that instruction It then repeats the process for the next instruction from memory and it repeats the process over and over until it is halted in some way A single fetch and execute cycle is itself made up of a number of smaller simpler steps Each step of the fetch and execute cycle is a simple operation that can be accomplished by turning control wires on and off Typical operations that can be performed in a single step include Load the address register from the program counter Add one to the program counter and Set the COUNT register to zero Question 4 Suppose that a main memory has 65536 locations How many address wires will that memory need Explain carefully why your answer is true Note 65536 is 2 16 Answer The main memory circuit would need 16 address wires The address wires are used to pick out one particular memory location Every possible combination of values for the address wires can specify a different memory location Since there are two possible values ON and OFF for each wire then with 16 wires

    Original URL path: http://math.hws.edu/TMCM/f97/quiz3.html (2016-02-07)
    Open archived version from archive

  • CS100 Fall 1997: Quiz #4
    a compiler and an interpreter Answer A CPU can only directly execute machine language instructions designed for that particular type of CPU Programs written in any other language have to be translated into this machine language before they can be executed Both compilers and interpreters are programs that translate instructions from another language into machine language The difference is that a compiler does the translation all at once producing a complete program expressed in machine language while an interpreter goes through the program translating one instruction at a time and carrying it out Question 3 The Java programming language is unusual in that the execution of a Java program involves both a compiler and an interpreter Explain how this works Answer A Java program is compiled into Java bytecode which is the machine language for the Java Virtual Machine This virtual machine does not really exist However real computers can use a Java bytecode interpreter to execute the compiled Java bytecode program The advantage of doing things this way is that a compiler is a complex and relatively slow program A Java bytecode interpreter on the other hand can be small and relatively fast Any computer that has a Java bytecode interpreter can execute the same compiled bytecode program This is important for a language that is meant to be downloaded over the Internet and run on many different types of computers Question 4 What is the difference between a Web browser program such as Netscape and a Web server program Answer A Web browser is used to view pages of information that have been published on the Web A Web server is responsible for providing those pages A Web server is a program running on a computer at some particular address such as www hws edu Sometimes the computer

    Original URL path: http://math.hws.edu/TMCM/f97/quiz4.html (2016-02-07)
    Open archived version from archive

  • CS100 Fall 1997: Quiz #5
    operating system but others consider the interface to be a specialized application program Question 2 An expansion slot can be used to add a new hardware device to a computer system Explain what this means how it works and what it has to do with the system bus Answer The bus is a set of wires that connects the CPU to other devices so that the CPU can communicate with those devices and control them An expansion slot provides a way for a new device to be plugged into the bus In this way any device that is designed to be plugged into the expansion slot can be added to the system The system does not have to be explicitly designed to support that device Of course besides plugging the device physically into the system you probably have to add a device driver to the operating system Otherwise the CPU won t know how to communicate with the device Question 3 Briefly explain the startup process that a computer goes through when it is first turned on Why is a startup process necessary in the first place Answer When a computer is turned off most of its memory the dynamic RAM is erased However part of the memory consists of ROM read only memory which stores information permanently even when the power is off The ROM contains a simple boot program that begins the process of rebuilding the contents of the memory and configuring all the hardware devices At the end of the process device drivers have been loaded the operating system is running and the whole system is ready to be used Question 4 Interrupts are one method of communication between the CPU and other devices Give at least two examples of how interrupts might be used What device

    Original URL path: http://math.hws.edu/TMCM/f97/quiz5.html (2016-02-07)
    Open archived version from archive

  • CS100 Fall 1997: Quiz #6
    the execution of the program is to continue correctly from that point For example a precondition of the statement x sqrt y is that y 0 since if y is less than zero the program will crash For programmers preconditions are a tool for thinking about programs When a programmer notices a precondition in a program the programmer can check to make sure that the precondition is in fact true If not the programmer can add some statements to the program that will make the precondition true A programmer who stays on the lookout for preconditions has a better chance of writing correct programs Question 3 A process is the sequence of states that a computer goes through as it executes a program What exactly is a state Answer A state consists of all the information in the computer that is relevant to the execution of the program at some particular instant of time The state includes for example the current values of all the variables in the program and the value of the program counter which tells the computer which instruction in the program is next to be executed The idea is that the program could be halted at that instant and the state could be saved Later if the state is restored the program can continue on just as if no interruption has occurred Question 4 Draw the figure that would be produced by the following xTurtle program DECLARE Len Len 5 LOOP forward Len Len Len 1 EXIT IF Len 0 turn 120 END LOOP Answer As the loop executes the variable Len takes on the values 5 4 3 2 and 1 Then when Len becomes equal to zero the loop ends So the program draws five connected line segments of length 5 4 3 2

    Original URL path: http://math.hws.edu/TMCM/f97/quiz6.html (2016-02-07)
    Open archived version from archive

  • CS100 Fall 1997: Quiz #7
    one of the roles that women played in the history of computing Answer There are several possible answers The first programmer Ada Lovelace was a woman who worked with Charles Babbage Most of the women computers who worked on firing tables during World War II were women Women did the actual programming of the ENIAC by setting switches and rewiring connections Question 4 According to the video Giant Brains when the ENIAC computer was fitted with special blinking lights for a publicity film what were those lights made from Answer Ping pong balls Question 5 According to the video Giant Brains what was Alan Turing s key insight about the nature of computing How did his view differ from that of most of his contemporaries Answer Turing realized that computers could do more than numerical calculations He saw that computers could work with arbitrary symbols and therefore could be employed to work on a limitless number of different tasks up to and including the simulation of intelligence His contemporaries saw computers as fast automatic calculators and therefore missed seeing their truly revolutionary potential Question 6 What is the basic difference between painting and drawing programs Answer In a painting program the user creates an image by coloring pixels The only data that the computer remembers is the color of each pixel The computer does not know about objects in the scene and therefore it is not possible for the user to manipulate those objects as such In a drawing program the computer keeps a database containing information about all the objects in the scene The computer renders the scene described by this database The objects can be manipulated by for example moving them rotating them resizing them or changing their color Question 7 Define the term rendering as it applies

    Original URL path: http://math.hws.edu/TMCM/f97/quiz7.html (2016-02-07)
    Open archived version from archive