0% found this document useful (0 votes)
251 views1 page

Comp 251 Assignment 2

This document contains 4 problems related to algorithms and data structures: 1) Design an algorithm for a 6-state Turing machine to subtract one number from another in unary notation. 2) Graph common growth functions on logarithmic scales to compare their growth rates. 3) Solve problem 3.5 from the textbook on Big O notation. 4) Prove or disprove whether the minimum distance between a blue and red point determines an edge in the minimum spanning tree of a set of points with both blue and red points.

Uploaded by

dergachev
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
251 views1 page

Comp 251 Assignment 2

This document contains 4 problems related to algorithms and data structures: 1) Design an algorithm for a 6-state Turing machine to subtract one number from another in unary notation. 2) Graph common growth functions on logarithmic scales to compare their growth rates. 3) Solve problem 3.5 from the textbook on Big O notation. 4) Prove or disprove whether the minimum distance between a blue and red point determines an edge in the minimum spanning tree of a set of points with both blue and red points.

Uploaded by

dergachev
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PS, PDF, TXT or read online on Scribd
You are on page 1/ 1

Data Structures and Algorithms COMP-251 A

Problem Assignment #2

1. Algorithms for Turing Machines


Let T(6) be a six-state Turing machine. Design an algorithm for T(6) that subtracts a num-
ber y from a number x. Your algorithm should work for any numbers that are positive inte-
gers of any finite size where x is greater than y. Assume the numbers are written on the tape
in unary notation and separated by one blank. Use the symbols R, L, X and - for: move right,
move left, make a mark and erase a mark, respectively. Assume the machine starts in state
1 and the reader is located on the leftmost mark on the tape. The machine should go to state
0 (stop) when finished. Let your instruction units (lines of code) be 4-tuples of the form (a,
A, B, b) where a denotes the present state, A takes on the symbols X or -, B takes on the
symbols R or L or X or -, and b denotes the next state entered.

2. Growth of Functions
Graph the functions 12n, 6n log n, n2, n3, and 2n using a logarithmic scale for the x and y
axes. In other words, if the function value f(n) is y, plot this as a point with x-coordinate at
log n and y-coordinate at log y.

3. Big “Oh” Notation


Problem 3.5 in the Udi Manber text.

4. Minimum Spanning Trees


Let S be a set of n>2 points in the plane in general position which is the union of two non-
empty sets of points B (blue) and R (red). Prove (by any method of your choice) or disprove
(by any method of your choice) that the minimum distance between a blue point and a red
point determines an edge in the MST(S), the minimum spanning tree of S. Points in general
position means that no three points lie on a line.

-1-

You might also like