CSC 132 Fall 2000

Lab 3

Due: end of today's lab, 28 September 2000

15 points

"Match Game"

You will need files IntList.java and IntListDriver.java from the eccentric download folder for Lab 3. The IntList class is fleshed out except for one private method, which you are to provide. The source code is well documented with javadoc-style comments so you can read about it here. It is an ADT for storing integers in a list. Note it is not the same as the IntNode class we are studying in lecture. IntList uses a private inner class called Node, and IntList methods provide all node and list maintenance.

Your assignment is to implement the private sublistMatch method, which is used by the position method. Position takes an IntList L as a parameter and returns the first position at which L occurs as a contiguous sublist within the current list. The list starts at position 0, and -1 is returned if L does not occur as a sublist.

Use IntListDriver.java to test your code. Its correct output:

source = <8, 6, 7, 7, 5, 3, 0, 9>

found <3, 0, 9> at position 5

found <6> at position 1

found <7, 5> at position 3

found <8, 6, 7, 7> at position 0

found <0, 9, 9> at position -1

found <2, 8, 6> at position -1

found <6, 5, 0> at position -1

 


[ Assignments | CSC 132 | Peter Sanderson | Computer Science | SMSU ]


Last reviewed: 26 September 2000

Peter Sanderson ( PeteSanderson@smsu.edu )