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".
  • CPSC 100 (Spring 1997) Weekly Guide
    concepts that are covered Each week I will assign some reading from the text and I will give you a list of the most important terms from the reading I will list the terms on the board in class and I will post the same list on this page I will also post a short summary of the weekly reading I will not always cover all the concepts in lecture

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


  • CS100 Spring 1997: Test #1
    Accumulator 5 ADD 21 Add the number in location 21 to the Accumulator 6 STO 20 Store the number in the Accumulator into location 20 7 LOD 21 Load the number in location 21 into the Accumulator 8 INC Add 1 to the number in the Accumulator 9 STO 21 Store the number in the Accumulator into location 21 10 SUB C 100 Subtract 100 from the Accumulator 11 JMZ 13 If the number in the Accumulator is 0 then jump to location 13 12 JMP 4 Jump to location 4 13 HLT Halt the computer b This program computes 1 2 3 99 The program begins by storing 0 in location 20 and 1 in location 21 Then it goes in a loop the part of the program from location 4 to location 12 In this loop the program first adds whatever is in location 21 into location 20 Thus the number in location 20 increases each time through the loop by whatever is in location 21 Then the program adds 1 to the value in location 21 So the number in location 21 starts at 1 then increases to 2 then to 3 then to 4 and so on as the computer executes the loop over and over In the meantime location 20 starts at 0 The first time through the loop 1 is added to this giving 1 The second time through 2 is added giving 1 2 The third time 3 is added giving 1 2 3 And so forth This stops when the SUB C command produces a value of zero which is when the value in location 21 has just become 100 At this time the value in location 21 is 1 2 3 99 Question 6 Define the following terms as they relate to this course a Pixel b Register c Control circuit a component of the CPU d Computational Universality Answer a A pixel is one of the small dots used to represent an image in digital form Each pixel can be individually assigned a color The screen of a computer is made up of pixels b A register is a memory unit that is part of the CPU A register holds a binary number that is being used directly in the ongoing computation being performed by the CPU c The control circuit is the circuit that decides what action to take at each step of the fetch and execute cycle Its uses inputs from the count register instruction register and accumulator to determine what needs to be done It carries out the appropriate action by turning control wires on and off d Computational universality refers to the fact that except for limitations imposed by the amount of time and memory available all computers are equivalent in the problems they can solve Question 7 Explain what is meant by structured complexity and give several examples from different areas such as computer science biology politics Answer Structured complexity is the main theme of

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

  • CS100 Spring 1997: Test #2
    loop is executed again This time the output is 4 and then the value of x is changed to 4 4 which is 16 Again 16 is not greater than 100 so the loop repeats The number 16 is drawn on the screen and the value of x is changed to 16 16 Since 16 16 is greater than 100 the loop ends and the program also ends The numbers that have been output onto the screen are 2 4 16 Question 5 Consider the following xTurtle program Explain in words what is accomplished by this program Don t just say what each line does describe the overall purpose of the program Also draw a picture that illustrates what the program might produce when it is run Because of the randomness in the program a different picture will be produced each time it is run however they are all basically similar DECLARE length DECLARE count count 0 LOOP face RandomInt 360 length RandomInt 5 forward length back length count count 1 EXIT IF count 100 END LOOP Answer The loop in this program is repeated 100 times Each time the loop is executed the computer chooses a random angle between 1 and 360 and a random length between 1 and 5 It then draws a line of that length radiating out from the point 0 0 at the selected angle The result is a starburst pattern consisting of 100 lines of lengths 1 2 3 4 and 5 radiating out from a common center Here are two pictures actually produced by this program Question 6 Explain the terms integrated circuit and microprocessor Answer Repeated from Quiz 4 An integrated circuit consists of several or perhaps millions transistors and other electronic components on a single small chip of silicon An integrated circuit is faster and more reliable than the same circuit made out of individual transistors A microprocessor is an integrated circuit that contains a complete CPU on a single chip It was the development of microprocessors that made today s cheap personal microcomputers possible Question 7 Define the term recursive subroutine Answer A recursive subroutine is one that calls itself either directly or indirectly Note A subroutine calls itself indirectly if it calls another subroutine that call back to itself either directly or indirectly This is a recursive definition Question 8 Consider the following recursive subroutine SUB Guess length complexity forward length IF complexity 0 THEN Guess length 3 complexity 1 END IF turn 120 forward length IF complexity 0 THEN Guess length 3 complexity 1 END IF turn 120 forward length IF complexity 0 THEN Guess length 3 complexity 1 END IF turn 120 END SUB Given this definition draw the picture that would be produced by each of the following subroutine call statements a Guess 9 0 b Guess 9 1 a Guess 9 2 Answer If the complexity is zero then the subroutine reduces to the statements forward length and turn 120 repeated three times The result

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

  • CS100 Spring 1997: Quiz #1
    each character is represented by an 8 bit binary number and there are 256 such possible codes In a newer text encoding scheme called Unicode each character is represented by a 16 bit binary number How many different possible 16 bit codes are there and why Answer There are 2 16 possible 16 bit codes That s 2 raised to the 16 th power which is 65536 Each bit doubles the number of possibilities The number of possibilites with 16 bits is 2 multiplied by itself 16 times Similarly an 8 bit code gives 256 possibilities because 256 is 2 raised to the eigth power Question 3 What is a CPU and what role does a CPU play in a computer Answer The CPU or Central Processing Unit is the active part of the computer which actually executes programs To execute a machine language program that is stored in main memory the CPU repeatedly fetches an instruction from memory and then executes that instruction Question 4 Programs can be written in high level language or in machine language What is the difference between these two types of programming languages Answer Machine language consists of instructions encoded as binary numbers These machine language instructions can be directly executed by the computer s CPU A high level language on the other hand is easier for humans to write or read but programs written in a high level language cannot be executed directly by the computer They must first be translated into the machine language that the computer understands Note In the category of most common mistakes The term machine language is defined to mean the programming language that can be executed directly by the hardware of a computer It does not refer to ASCII code ASCII code is used to encode data

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

  • CS100 Spring 1997: Quiz #2
    few transistors Logic gates can be combined to produce larger more complex circuits The association between gates and logic is useful because logic can be used as a tool for building and understanding circuits Question 2 Consider the following circuit Write down the logical expression that expresses the output of the circuit in terms of the three inputs A B and C Answer A or not B and not B or C Note This formula is obtained by working from left to right and finding a formula for the output of each logic gate in the diagram The leftmost NOT gate computes the value of the expression not B The top OR gate combines this value with A to compute A and not B And so on Question 3 Add the following two binary numbers 1 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 Answer Here is the sum shown with the answer and the carry from each column to the next shown in red 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 1 0 1 0 1 1 0 0 Question 4 Explain briefly 1 What is the purpose of a full adder circuit and 2 How can a circuit for adding two 16 bit binary numbers be built from full adders Answer A full adder is a circuit that computes the sum of three bits and gives a two bit answer A circuit for adding two 16 bit numbers can be built from 16 full adder circuits Each full adder does one column of the sum The full adder for a given column adds two bits

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

  • CS100 Spring 1997: Quiz #3
    of these instructions tells the CPU to add a number to the value that is already stored in the accumulater and to put the resulting sum back into the accumulator However for the ADD 42 instruction the number to be added is whatever happens to be stored in memory location number 42 For the ADD C 42 instruction on the other hand the number to be added in the number 42 itself Question 3 The clock in xCompter does not keep time What role does it play Answer The clocs ticks by turning an output wire on and off Each time this wire is turned on and off one step of the fetch and execute cycle is performed Thus the ticking of the clock drives the whole operation of the CPU Note The clock in xComputer also has a control wire named Stop Clock When this wire is off the clock ticks and the computer runs when it is on the clock does not tick so the computer is not operating But this doens t mean that the main purpose of the clock is to turn the computer on and off Question 4 Every fetch and execute cycle in xComputer begins with the same three substeps State the purpose of doing each of these steps Why is the step necessary Load ADDR from PC that is copy the contents of the program counter register into the address register Load IR from memory that is copy the number on memory s data out wires into the instruction register Increment PC that is add one to the value in the program counter register Answer At the beginning of the fetch and execute cycle the address of the next instruction in memory is stored in the program counter register The computer must fetch

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

  • CS100 Spring 1997: Quiz #4
    considered to be the first programmer Unfortunately their work was almost forgotten for one hundred years and was only rediscovered after the first computers were built in the mid 1900s Question 2 What were the contributions of John Mauchly and J Presper Eckert to the history of computing Answer Eckert and Mauchly built the ENIAC the first electronic programmable computer The ENIAC was begun during World War II to do military computations but it wasn t actually finished until after the war To be reprogrammed the ENIAC had to be physically re wired However even before the ENIAC was complete Eckert and Mauchly had come up with the idea of a stored program computer in which the program would be stored as information in the computer s memory In a stored program computer the programming can be changed easily just by loading a new program into memory Later Eckert and Mauchly went on to found the first commercial computer company Question 3 What is a device driver and why are device drivers essential to the functioning of a real computer system Answer A device driver is the software that the CPU executes in order to communicate with and control another device such as the keyboard a sound card a network interface card etc A device driver consists of subroutines and interrupt handlers specific to one particular type of device Connecting a device physically to the computer is not enough to make it usable the device driver must also be added to the system software Question 4 Explain the terms integrated circuit and microprocessor Answer An integrated circuit consists of several or perhaps millions transistors and other electronic components on a single small chip of silicon An integrated circuit is faster and more reliable than the same circuit made out of

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

  • CS100 Spring 1997: Quiz #4
    at a particular instant during the execution of that program For example the state includes the values of all the variables used in the program It includes an indication of which statement in the program is being executed And in xTurtle it includes the position and heading of the turtle A process consists of the sequence of states that the computer goes through as it executes the program The program is a kind of script for the process but a process is dynamic it is something that takes place over a period of time Question 2 What is a variable Give as full an answer as possible Answer A variable is a named memory location that can store a value Since a variable in a program is referred to by name the programmer doesn t have to worry about the address of the memory location When the variable is used in the program it can refer either to the memory location itself or to the value stored in that memory location Question 3 Draw the picture that would be produced by the following xTurtle program DECLARE count count 0 LOOP forward 5 turn 90 forward 1 back 2 forward 1 turn 90 back 5 turn 45 count count 1 EXIT IF count 5 END LOOP Answer Each repetitition of the loop draws a T shaped figure Five such figures fan out from the turtle s starting position separated by angles of 45 degrees At the end the turtle is back where it started from at a heading of 225 degrees Question 4 Write an xTurtle program that will draw the following picture The picture consists of ten identical squares Use a loop Answer There are many possible answers Here is a typical program with comments to explain what it does

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