Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS 331 Project #3: Implementing a Character String ADT using Java and LinkedList, Study Guides, Projects, Research of Data Structures and Algorithms

Project #3 for cs 331, due on october 13, 2004. Students are required to implement the abstract data type (adt) character string using a linked list of characters. Correspondences between adt list operations and java's linkedlist methods, instructions for creating the adt character string, and key concepts for the operations. Students must write a java client program to test the adt operations.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 08/18/2009

koofers-user-i45-1
koofers-user-i45-1 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 331 Project #3 Oct. 4, 2004
Page 1 of 2
Due at start of class on Wednesday, Oct. 13, 2004
50 points.
Refer to Exercise 5, page 210, textbook.
A referenced-based implementation of the ADT list was discussed (pages 176 to 180, Textbook)
Class java.util.LinkedList implements the List interface. The correspondences
between ADT List and class java.util.LinkedList are as below:
ADT List operations java.util.LinkedList methods
createList() LinkedList ()
LinkedList (Collection c)
isEmpty() isEmpty()
size() size()
add(index, item) add(int index, Object element)
addFirst(Object o)
addLast(Object o)
addAll(Collection c)
addAll(int index, Collection c)
remove(index) remove (int index)
removeFirst()
removeLast()
remove(item) remove (Object o)
removeAll() clear()
removeRange(int fromIndex, int toIndex)
get(index) get(int index)
getFirst()
getLast()
locateIndex(item) indexOf (Object o)
lastIndexOf()
replace(index, newItem) set(int index, Object element)
subList(int fromIndex, int toIndex)
equals(Object o)
containsAll(Collection c)
iterator()
listIterator(int index)
Implement the ADT character string by using a linked list of characters.
Include typical operations such as
append one string to another,
extract a substring,
find the index of the leftmost occurrence of a character in a string,
determine whether one string is a substring of another.
determine whether two strings are identical to each other.
pf2

Partial preview of the text

Download CS 331 Project #3: Implementing a Character String ADT using Java and LinkedList and more Study Guides, Projects, Research Data Structures and Algorithms in PDF only on Docsity!

CS 331 Project #3 Oct. 4, 2004

Page 1 of 2

Due at start of class on Wednesday, Oct. 13, 2004 50 points.

Refer to Exercise 5, page 210, textbook.

A referenced-based implementation of the ADT list was discussed (pages 176 to 180, Textbook) Class java.util.LinkedList implements the List interface. The correspondences between ADT List and class java.util.LinkedList are as below:

ADT List operations (^) java.util.LinkedList methods createList() LinkedList^ () LinkedList (Collection c) isEmpty() isEmpty () size() size () add(index, item) add (int index, Object element) addFirst (Object o) addLast (Object o) addAll (Collection c) addAll (int index, Collection c) remove(index) remove^ (int index) removeFirst () removeLast () remove(item) remove^ ( Object^ o) removeAll() clear () removeRange (int fromIndex, int toIndex) get(index) get (int index) getFirst () getLast () locateIndex(item) indexOf^ (Object o) lastIndexOf () replace(index, newItem) set (int index, Object element) subList (int fromIndex, int toIndex) equals (Object o) containsAll (Collection c) iterator() listIterator (int index)

Implement the ADT character string by using a linked list of characters. Include typical operations such as append one string to another, extract a substring, find the index of the leftmost occurrence of a character in a string, determine whether one string is a substring of another. determine whether two strings are identical to each other.

CS 331 Project #3 Oct. 4, 2004

Page 2 of 2

Key concepts of ADT character string operations

  1. Create an empty linked list
  2. Determine whether the linked list is an empty character string.
  3. Determine the number of characters in the linked list
  4. Add a character at the end of the linked list
  5. Determine whether one string is a substring of another

The class for the ADT character string has to include the following: Define a StringNode class (page 163, Textbook) Declare head, prev, curr reference variables and a size variable Define a method append(string1, string2) Define a method extract(fromPosition) Define a method extract(fromPosition, toPosition) Define a method find(character) Define a method isSubstring(string1, string2)

Implementing above ADT using Java. Write a Java client program which uses above ADT operations to do: (10 points each)

a. appending one string to another, b. extracting a substring, c. finding the index of the leftmost occurrence of a character in a string, d. determining whether one string is a substring of another e. determining whether two strings are identical to each other.