Homework 2 - Binary/Hex/DynamicSet


Due Monday April 7, 1997

Reading: Oualline: pages229-237, chapter 13, pages 435-443

1. (->*& and all that) based on problem 2.17 in Ford and Topp
For the following code segment, show the values of x, y, *p, *q at the five places indicated.

	int	x = 5;	
	int y = 7;
	int *p = &x;
	int *q = &y;		// 1a.	x, y, *p, *q

	(*p)--;				// 1b.	x, y, *p, *q

	*q += *p;			// 1c.	x, y, *p, *q

	q = p;				// 1d.	x, y, *p, *q

	*q = 55; 			// 1e.	x, y, *p, *q

2. (arrays and pointers ) also based on problem 2.17 in Ford and Topp
For the following code segment, show the values of *Dptr and the contents of the array D[] at the six places indicated.

	double D[] = {3.1, 5.2, 4.4, 0.1, -5.0, 0.0, 9.8};
	double* Dptr = D;	
							// 2a.	contents of D[]; value of *Dptr
	*Dptr += 7.7;
							// 2b.	contents of D[]; value of *Dptr
	Dptr++;
							// 2c.	contents of D[]; value of *Dptr
	*Dptr++ = 9.9;
							// 2d.	contents of D[]; value of *Dptr
	Dptr +=2;
							// 2e.	contents of D[]; value of *Dptr
	*++Dptr = 8.8;
							// 2f.	contents of D[]; value of *Dptr

3. (a bit of binary)
a. Compute the decimal value of each of the following binary numbers

b. Find the binary value of each of the following decimal numbers
4. (a heap of hex)
a. Compute the decimal value of each of the following hex(adecimal)
numbers b. Compute the hex value of each of the following decimal numbers
c. Compute the binary value of each of the following hex(adecimal) numbers
d. Compute the hex value of each of the following binary numbers

5. Write the declarations only for a class DynamicSet that has objects of template class T. The first programming assignment - to be started in lab Tuesday April 8, will involve implementing and using this class.

Include pre- and post- conditions in your member function declarations!

Cormen, Leiserson, & Rivest in "Introduction to Algorithms", McGraw Hill & MIT Press, 1990, page 197 define a Dynamic Set a collection of objects whose fields can be manipulated if we have a pointer to the object. There are two types of operations that can be performed on a Dynamic Set S:

Queries:

Modifying Operations:

Last Updated: April 6, 1997 11:48 am by

Harriet Fell
College of Computer Science, Northeastern University
360 Huntington Avenue #161CN,
Boston, MA 02115
Internet: fell@ccs.neu.edu
Phone: (617) 373-2198 / Fax: (617) 373-5121
The URL for this document is: http://www.ccs.neu.edu/home/fell/COM1101/HW/HW2/hw2.html