Commit 7eb1deda authored by Christophe Rhodes's avatar Christophe Rhodes

updates to 07

parent 80c1016f
#+TITLE: Algorithms & Data Structures: Lab 07
#+SUBTITLE: week of 19th November 2018
#+include: ../
* Setup
** Saving your work from last week
As with all previous weeks, you will use =git= to download a bundle
of lab code. You will probably have made modifications in your
downloaded copy; if you have not already done so, you need to save
those modifications. First examine the changes present in your
downloaded copy by issuing the following commands from the labs
git status
git diff
and if you are satisfied with the changes, store them in the git
version control system by doing
git commit -a
and writing a suitable commit message
** Downloading this week's distribution
Once you have successfully saved your changes from last week, you
can get my updates by doing
git pull
which /should/ automatically merge in new content. After the =git
pull= command, you should have a new directory containing this
week's material (named =07/=) alongside the existing directories.
* List visualiser
** Implementing a class to visualise a list
You have (in labs 04-06) already implemented a singly-linked list
class in terms of =SLList= objects. For this part of the lab, you
must implement a method to visualise a linked list object.
Specifically, you must implement a =ListVisualiser= class, with:
* a constructor accepting a single SLList reference – prototype
~ListVisualiser(SLList)~ (Java) / ~ListVisualiser(SLList *)~
(C++); and
* a public method =visualise()= (Java) / =visualise()= (C++).
The ~visualise()~ method should display the list given in the
constructor using the box-and-pointer notation you should be
familiar with from lecture slides. You may use any reasonable
ASCII text-based representation, for example representing the list
~(1, 11, 23)~ as
| | |
1 11 23
or at your own risk you can implement a more advanced
visualisation, for example using Unicode box-drawing characters,
a graphical library, or output to HTML.
You may find it helpful to test your visualiser using your own
=SLList= implementation and my provided test file, using ~make
test~. You may also wish to consider other cases not covered by my
test file, and extend my provided test file to cover those.
** Peer-assessment
You must submit your =ListVisualiser= source code, along with any
auxiliary files it needs to build (/e.g./ a header file) but *not*
your =SLList= implementation, to the [[][List Visualiser Activity on]] by *16:00* on *Friday 30th November*.
You should include in your submission, which can be a ZIP file, any
instructions for compilation or use of your code which would be
helpful to another member of the class, as they will need to be
able to compile and use your code in order to assess it and provide
you with feedback.
Failure to submit your source code will lead to an *automatic mark
of zero* for both the submission *and* the assessment portion of
this activity. There *no extensions* to the deadline of 16:00 on
Friday 30th November.
#include "SLList.hpp"
#include "ListVisualiser.hpp"
ListVisualiser::ListVisualiser(SLList *a) {
void ListVisualiser::visualise() {
#include "SLList.hpp"
class ListVisualiser {
ListVisualiser(SLList *);
void visualise();
#include "SLList.hpp"
#include "ListVisualiser.hpp"
int main() {
SLList *a = new SLList(1, new SLList(11, new SLList(23, SLList::NIL)));
ListVisualiser v = ListVisualiser(a);
return 0;
include ../../
LDLIBS += -lm
ListVisualiserDriver: CPPFLAGS += -I ../../04/cpp
ListVisualiserDriver: ListVisualiser.o ../../04/cpp/SLList.o ListVisualiserDriver.o
test: ListVisualiserDriver
.PHONY: test
public class ListVisualiser {
public ListVisualiser(SLList l) { }
public void visualise() {
public class ListVisualiserDriver {
public static void main(String args[]) {
SLList a = new SLList(1, new SLList(11, new SLList(23, SLList.NIL)));
ListVisualiser v = new ListVisualiser(a);
include ../../
CLASSFILES = ../../04/java/SLList.class ListVisualiser.class ListVisualiserDriver.class $(TESTCLASSFILES)
CLASSPATHS += ../../04/java
-rm -f $(TESTCLASSFILES) test.xml
test: all
$(JAVA) -Xss10m $(CP) $(CLASSPATH) ListVisualiserDriver
.PHONY: test all clean
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment