// hw3_string.h struct String; struct String* string_new(char* str); void string_free(struct String* s); struct String* string_clone(struct String* s); int string_length(struct String* s); void string_append(struct String* a, char* b); char string_charAtIndex(struct String* s, int index); char* string_range(struct String* s, int start, int length); char* string_chars(struct String* s);The template for hw3 is available at
svn://bits.cs.uic.edu/cs385/pub/homeworks/hw3
. This contains the hw3_string.h
above, an implementation of the String data structure called simple_string.c
, and programs that use String data structures and tests their correctness and runtime performance.
fast_string.c
. You may implement your data structure whichever way you please, as long as the following conditions hold:
dmalloc()
and dfree()
instead of malloc()
and free()
. Also uses no other functions (like mmap() or remalloc()) for dynamic memory allocation.
make testunit
without warnings
make testspeed
simple_string.c
to a new file fast_string.c
, and edit the first line of the Makefile
to use fast_string.c
instead. Make and commit your changes to fast_string.c.
make testunit
. This performs several unit tests on the String functions declared above. Try running make testunit
with STRING_CODE
in the Makefile
set to simple_string.c
to see the expected output.
To test the performance of your code, run make testspeed
. This downloads a large book, concatenates the entire book into one large string, line by line, and applies the string functions on the resulting string. make testspeed
also outputs a series of "Found characters" and "Excerpts". These outputs are identical for all correct solutions - if your output differs, it will be deemed incorrect.
make testspeed
. original_speed
runs the code provided in the template. unbalanced_speed
runs an early solution I wrote, and balanced_speed
runs my best solution.
To try one, run (for example) ./balanced_speed pg2554.txt
. Your solution is expected to either finish in at most 10 times the total time of balanced_speed
, or finish the "reading book" part in at most 2 times that of unbalanced_speed
, and the lookup in at most 1.5x that of unbalanced_speed
.
Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu |
WISEST Helping Women Faculty Advance Funded by NSF | ![]() | ![]() |