CSCI 150, Spring 2003

Home | | Course Schedule | | Assignments | | Lecture Notes

Review sheet for 2nd midterm

Topics for Exam2:
This sheet is intended to help you prepare for the second midterm exam in this course. The exam will primarily focus on chapters 4, 5, and 7 of the textbook and all the lectures and labs through Wednesday, 3/26/03. However, there will also be some questions from the beginning part of the course so you should review chapters 1 - 3 and your notes on Pascal programming as well. You should study your class notes, handouts, homeworks and labs. Solutions to the homeworks and labs can be found at the course website: http://mathcs.holycross.edu/~csci150. The readings include the following: Ch 4, 5, 7 of the textbook.

The following topics have been covered in the second part of the course. Each of the following topics may appear on the exam. In addition there may be questions on any of the topics from the first part of the course.

1.  Subprograms
	Divide and conquer programming
	Procedures
		Writing Procedure definitions
		Calling a procedure
		Execution of a procedure
		Formal and actual parameters
		Pass-by-Reference and Pass-by-Value parameters
	functions
		writing function definitions
		Returning a value from a function
2.  Recursion
	Definition of recursion
	Writing a recursive function (one that calls itself)
	Classic examples of recursion: Fibonacci, Factorial

3.  Church-Markov-Turing Hypothesis

4.  Simulation
	Purpose of simulations (what are they good for?)
		observing system behavior under different conditions
		designing systems that behave optimally
		increasing understanding of a system
	Altering code to find best solution to a problem (e.g. race car code)

5.  Binary representation
	Counting in base 2
	Converting from decimal to base 2 (and back)
	Hexadecimal representation (base 16)
	Integer representation--Signed magnitude, One's complement, Two's complement
	Binary arithmetic	
	Floating point representation

6.  Digital Circuits
	Components:
		Logic switches, AND, OR, NOT, NAND, NOR and XOR
	Writing Truth tables for circuit outputs
	Writing logical expressions to describe circuit outputs
	Designing a circuit to compute a logical expression


Practice Problems
The following problems are intended to help you study for the exam. Solutions to these problems will be posted on the CSCI 150 website at the end of the weekend. You should try to solve the problems before looking at the solutions!

1)  Given the function definition:
	function Mystery( someVal: real): real;
	begin
		if  someVal > 2.0 then
		begin
			Mystery :=  3.0 * someVal;
		end
		else
		begin
			Mystery :=  0.0;
		end;
	end;

What is the value is assigned to x after execution of the following statement?
	x := Mystery(2.5);







2)  Consider the procedure definition:
	procedure Demo( var number: integer; answer: real);
	begin
		number := number*2;
		answer := number + 3.5;
	end;

Suppose the caller has variables myNum and myResult whose values are 20 and 4.8 respectively.  
What are the values of myNum and myResult after return from the following procedure call?
	Demo(myNum, myResult);









3)  a)Write a function, 
	function TenToThePower( n : integer) : integer;
that returns 10 raised to the integer power specified by n.






b)  Write a Pascal statement to compute 10 to the power of 3 and store the answer in the variable, 
tenCubed.





4)  Convert the following numbers to binary representation:

	237

	45

	63

5)  Convert the above numbers to hexadecimal representation





6)  For each of the following numbers, show their representations in each of: signed magnitude, 1's 
complement and 2's complement:

	22

	-31

	-22

	49


7)  Using eight bit numbers, add the following two binary numbers:

	01110001
	00011100

Show your work.
Convert the result to decimal.


8) Draw a circuit that computes the following truth table for inputs a and b and output c:

abc
000
011
101
110

9) Write an expression for the output of the following circuit. Draw a truth table that shows the output for each combination of inputs: