• Keine Ergebnisse gefunden

Übung 02: Ringliste

N/A
N/A
Protected

Academic year: 2022

Aktie "Übung 02: Ringliste"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Übung Praktische Informatik 2 SS 2008

Übung 02: Ringliste

Abgabetermin: 01.04.2008 12:00

Name: Matrikelnummer:

Gruppe: ❒ G1 (Wolfinger)

Aufgabe Punkte gelöst abzugeben schriftlich abzugeben elektronisch

Korr. Pkte

Aufgabe 02.1 24 Java-Programm

Testfälle und Ergebnisse

Java-Programm

Aufgabe 02.1: Wortliste als Ringliste mit Kopfknoten

Implementieren Sie in der Klasse SortedWordList eine sortierte Ringliste mit Kopfknoten, die die Häufigkeit der eingefügten Wörter zählt und statistische Auswertungen ermöglicht. Es soll nicht zwischen Groß- und Kleinschreibung unterschieden werden.

class SortedWordList implements WordList { private WordNode head;

public SortedWordList () {…}

}

class Word {

int count; // frequency String word;

public Word(…) {…}

}

class WordNode { Word data;

WordNode next; // next node in list public WordNode(…) {…}

}

Die Klasse SortedWordList soll das folgende Interface WordList implementieren:

public interface WordList { // Insert a word

void insert(String word);

// Remove a word

void remove(String word);

// Get frequency of word

int getFrequency(String word);

// Number of different words int nOfDifferentWords();

// Mean frequency of equal words double meanWordCount();

// Get all words with specified frequency String[] getWords(int frequency);

// Get all words starting with the specified prefix String[] getWordsStartingWith(String prefix);

void print();

// Creates a copy WordList clone();

// Merges two lists

void merge(WordList list);

// Gets an iterator Iterator iterator();

}

(2)

Übung Praktische Informatik 2 SS 2008

Beispiel: Einlesen von "To be or not to be" soll beim Aufruf der Methode print in etwa folgende (Test-)Ausgabe liefern (Reihenfolge aufsteigend sortiert):

1 BE (2 times) 2 NOT (1 times) 3 OR (1 times) 4 TO (2 times)

Die Methode nOfDifferentWords liefert in diesem Beispiel das Ergebnis 4, meanWordCount liefert 1.5 (versuchen Sie bei der Implementierung ohne Schleifen auszukommen).

Implementierungshinweis:

Die Methode merge ist so zu implementieren, dass die Knoten der übergebenen Liste list dupliziert und in die durch this referenzierte Liste einsortiert werden. Verwenden Sie dazu nicht die insert-Methode, sondern duplizieren (clone) Sie die Knoten aus list und ketten Sie die duplizierten Knoten in this ein. Der Eingangsparameter list ist vom Typ WordList

(interface), Sie haben daher keinen Zugriff auf den head-Knoten. Verwenden Sie stattdessen den Iterator um die übergebene Liste zu durchlaufen.

Der Iterator soll Objekte vom Typ Word liefern.

Testen Sie Ihre Implementierung mit der Datei alice.txt aus der Vorgabedatei.

Abzugeben ist:

Das Java-Programm

Testfälle und die Ergebnisse

Referenzen

ÄHNLICHE DOKUMENTE

The receiver active circuit monitors the serial received data line from the peripheral interface and a receiver done (RDONE H) status bit from the RBUF.. The

Installation of the DRVII-WA general-purpose DMA interface con- sists of selecting the device and interrupt vector addresses, selecting mode of operation (18- or

If external synchronous or isochronous mode is selected, this bit follows the state of the search sync bit (bit 04 of this register). Refer to Paragraph 5.3 for

Received characters are transferred from the serial interface to the host via PROC2, the RX FIFO, and the UNIBUS data transceivers.. At the center of the control section is a

The transmitter control logic provides the necessary input, control, and output logic for the UART when it is used to convert parallel data from the Unibus to

When a received character (in RX buffer register) or a character to be transmitted (in TX shift hold register) matches any character in the character detect

When data is loaded into the output register, a byte-oriented control signal (INTERNAL DATA READY) is sent to the external device requesting it to read the output

plexed togethel In a sysklll and have separate Drive Select lilies. For additional methods of selecting drive'i. The access motion is initialed on each logical/ero to