-
Programming Help
Hey everyone, I have a JAVA program due tomorrow and I'm soo stressed out with it. I've been working on it for hours now and have like nothing to show for it, if anyone could help me that would be AWESOME! here is the program details:
With x and y being (possibly empty) sequences, ~ the concatenation operator, and () an empty sequence, the operations on sequences are defined as follows:
{true} CreateSeq (x) {x = ()}
{x = (c)~y} a := First (x) {a = c AND x = (c)~y}
{x = (c)~y} GetFirst (x, v) {v = c AND x = y}
{x = y~(c)} GetLast (x, v) {v = c AND x = y}
{x = y} PutFirst (x, c) {x = (c)~y}
{x = y} PutLast (x, c) {x = y~(c)}
{x = X} SeqIsMT (x) {SeqIsMT (x) = (X = ())}
a) Implement a sequence class in javac. Please implement all seven operations defined above.
b) Using this sequence class, solve the following problem. The input is a text-string containing alfabetical characters as well as {, }, (, ), [ and ] characters. Check the input to see if each open- and close-bracket is matched.
An example is given here:
(({A}bc{D})[ef])g
is correct because each pair of brackets encloses a correct sub-string. More examples:
((a)} is not correct
a is correct
{} is correct
)( is wrong
(a)} is not correct
c) Test your implementation using the following test cases:
(({A}bc{D})[ef])g
(((((A)(bcd))))
{[({[(a)]})]}
()
Also test on an empty text string.
Thanks a lot, John
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks