Hierarchies of LifeExperiment 1 Classification of Common Objects.docx
1. Hierarchies of LifeExperiment 1: Classification of Common
Objects
Data Tables (15 points)
Post-Lab Questions
1. Did you find that the items grouped together as you worked
down the flow chart had similar characteristics in terms of their
appearance? What about function? (10 points)
A lot of the groups had similar characteristics and function,
until I looked deeper into then as I continued down the list of
questions. For example, a candle and a Scentsy are similar in
function and characteristics, as they both give off pleasant
smells. But if you were to ask if they use fire, you’d be able to
differentiate the two.
2. Do you feel that the questions asked were appropriate? What
questions would you have asked to devise this classification
flow chart? What objects would be grouped together with your
system? (10 points)
I had to look over the chart a few times and soon made sense of
the flow. I found myself conflicted on some of the answers as
well, not agreeing with some entirely. For example, I don’t
think a hex nut is cylindrical or round. It has sides, similar to
pens and pencils where the style if hex like.
3. Do you think it is more or less challenging to classify living
organisms in comparison to objects? Why? (10 points)
4. Pick 10 household items (e.g. spoon, book, paper clip, etc.)
and design a taxonomic classification system to categorize
them, similar to the one in Figure 8. Make sure you ask enough
yes/no questions so that each item ends up in its own box or
category at the end. (10 points)
2. Experiment 2: Classification of Organisms
Data Tables (10 points)
Table 2: Classification of Organisms
Organism
Domain
Kingdom
Defined Nucleus
Mobile
Photosynthesis
Unicellular
Salmonella
Bacteria
Genus
No
Yes
Yes
Yes
Ants
Eukarya
Animalia
Yes
Yes
No
No
Zoo Flagellate
Eukarya
Protozoa
Yes
Yes
No
Yes
Wolf
Eukarya
Animalia
6. 14 | XXXX
13 | XXXX
12 | XXXXX
11 | XXXXX
10 | X XXXXXXX
9 | XX XXXXXXX
8 | XXX XXXXXXXX
7 | XXXX XXXXXXXX
6 | XXXXX XXXXXXXXX
5 | XXXXXX XXXXXXXXX
4 | XXXXXXX XXXXXXXXXX
3 | XXXXXXXX XXXXXXXXXX
2 | XXXXXXXXXXXXXXXXXXXX
1 | XXXXXXXXXXXXXXXXXXXXX
0 |XXXXXXXXXXXXXXXXXXXXXX
+----+----+----+----+-
0 5 10 15 20
DEMO DATA 3
===========
length: 50
min: 13
max: 996
range: 983
max_height: 10
units_per_height: 98.30
+----+----+----+----+----+----+----+----+----+----
996 | X
897 | X X X X
799 | X X X X X X X X X
701 | XX X X X XXX X XX XXX X X XX
602 | XX X X XX XXX X X XX XXXX XX X XX
504 | XX XXX XX XXX XX X XXX XXXX XX XX X
XX
406 | XX X XXX XXXX XXX XX X XXX XXX
XXXXXXXXXX X XX
7. 307 | XXX X XXX XXXXXXXXXXX X XXXX
XXXXXXXXXXXXXXX X XX
209 | XXX XXXXXXXXXXXXXXXXX XXXXXX
XXXXXXXXXXXXXXXXX XX
111 |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXX
13
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXX
+----+----+----+----+----+----+----+----+----+----
0 5 10 15 20 25 30 35 40 45
DEMO DATA 4
===========
length: 50
min: 13
max: 996
range: 983
max_height: 18
units_per_height: 54.61
+----+----+----+----+----+----+----+----+----+----
996 | X
941 | X X
886 | X X X X
832 | X X X X X X
777 | X X X X XXX X X XXX XX
722 | XX X X X XXX X X XXX XX
668 | XX X X X XXX X XX XXXX X X XX
613 | XX X X XX XXX X XX XXXX XX X XX
559 | XX XXX XX XXX XX X XX XXXX X XX X XX
504 | XX XXX XX XXX XX X XXX XXXX XX XX X
XX
449 | XX X XXX XXXX XXX XX X X XXX XXXX XX XX
X XX
395 | XXX X XXX XXXX XXX XX X XXX XXX
8. XXXXXXXXXX X XX
340 | XXX X XXX XXXXXXXXXXX X XXX
XXXXXXXXXXXXXXX X XX
286 | XXX X XXX XXXXXXXXXXX X XXXX
XXXXXXXXXXXXXXX X XX
231 | XXX X XXXXXXXXXXXXXXX XXXXXX
XXXXXXXXXXXXXXXXX XX
176 | XXX XXXXXXXXXXXXXXXXX XXXXXX
XXXXXXXXXXXXXXXXXXXX
122 |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXX
67 |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXX
13
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXX
+----+----+----+----+----+----+----+----+----+----
0 5 10 15 20 25 30 35 40 45
ENDOUT
__MACOSX/a1-code/._test_print_graph_data.sh
a1-code/.DS_Store
__MACOSX/a1-code/._.DS_Store
a1-code/print_graph_demo.c
#include <stdio.h>
void print_graph(int *data, int len, int max_height);
int main(int argc, char *argv[]){
10. __MACOSX/a1-code/._print_graph_demo.c
a1-code/deltas.txt
10 2 5 -2 -5 -5 -6 4
a1-code/test_hash_main.sh
#!/bin/bash
# tests for print_graph_demo, run as one of
# > ./test_tree_main.sh # run everything
# > ./test_tree_main.sh 2 # run only tests 2
#
# 15 points for tests
# 5 points for valgrind tests
function major_sep(){
printf '%sn'
'====================================='
}
function minor_sep(){
printf '%sn' '-------------------------------------'
}
major_sep
printf "PROBLEM 3 hash_main.cn"
generate=1
run_norm=1 # run normal tests
run_valg=1 # run valgrind tests
valg_denom=3 # divide valgrind score by
this for points
# Determine column width of the terminal
if [[ -z "$COLUMNS" ]]; then
11. printf "Setting COLUMNS based on sttyn"
COLUMNS=$(stty size | awk '{print $2}')
fi
if (($COLUMNS == 0)); then
COLUMNS=126
fi
printf "COLUMNS is $COLUMNSn"
DIFF="diff -bBy -W $COLUMNS" # -b ignore
whitespace, -B ignore blank lines, -y do side-by-side
comparison, -W to increase width of columns
VALGRIND="valgrind --leak-check=full --show-leak-
kinds=all"
INPUT=test-data/input.tmp # name for expected
output file
EXPECT=test-data/expect.tmp # name for expected
output file
ACTUAL=test-data/actual.tmp # name for actual
output file
DIFFOUT=test-data/diff.tmp # name for diff output
file
VALGOUT=test-data/valgrind.tmp # name for valgrind
output file
printf "Loading tests... "
source test_hash_main_data.sh
printf "%d tests loadedn" "$T"
NTESTS=$T
VTESTS=$T
NPASS=0
NVALG=0
12. all_tests=$(seq $NTESTS)
case "$1" in
norm)
run_valg=0
shift
;;
valg)
run_norm=0
shift
;;
esac
# Check whether a single test is being run
single_test=$1
if ((single_test > 0 && single_test <= NTESTS)); then
printf "Running single TEST %dn" "$single_test"
all_tests=$single_test
NTESTS=1
VTESTS=1
else
printf "Running %d testsn" "$NTESTS"
fi
# printf "tests: %sn" "$all_tests"
printf "n"
# Run normal tests: capture output and check against expected
if [ "$run_norm" = "1" ]; then
minor_sep
printf "hash_main NORMAL TESTSn"
for i in $all_tests; do
printf "TEST %2d %-18s : " "$i" "${tnames[i]}"
FAIL="0"
# Run the test
13. # run program with given input
{ printf "%sn" "${input[i]}" | ./hash_main -echo ; } >&
$ACTUAL
# generate expected output
printf "%sn" "${output[i]}" > $EXPECT
# Check for output differences, print side-by-side diff if
problems
if ! $DIFF $EXPECT $ACTUAL > $DIFFOUT
then
printf "FAIL: Output Incorrectn"
minor_sep
printf "INPUT:n%sn" "${input[i]}"
# Mac OSX has a different version sed so use awk to
add on the ACTUAL/EXPECT
$DIFF <(awk 'BEGIN{print "***EXPECT
OUTPUT***"} {print}' $EXPECT) <(awk 'BEGIN{print
"***ACTUAL OUTPUT***"} {print}' $ACTUAL) >
$DIFFOUT # regen the diff with the headers
cat $DIFFOUT
if [ "$generate" == "1" ]; then
printf "%sn" "---FULL ACTUAL---"
cat $ACTUAL
echo
fi
minor_sep
FAIL="1"
fi
if [ -n "${tfiles[i]}" ]; then # if there is an
output file to check
TEXPECT=test-data/texpect.tmp # name for
expected output file
TACTUAL="${tfiles[i]}" # name for
actual output file
14. TDIFFOUT=test-data/tdiff.tmp # name for
diff output file
# generate expected output
printf "%sn" "${tfiles_expect[i]}" > $TEXPECT
# Check for output differences, print side-by-side diff if
problems
if ! $DIFF $TEXPECT $TACTUAL > $TDIFFOUT
then
printf "FAIL: File %s incorrectn" "$TACTUAL"
minor_sep
printf "INPUT:n%sn" "${input[i]}"
printf "OUTPUT: EXPECT vs ACTUALn"
cat $TDIFFOUT
if [ "$generate" == "1" ]; then
printf "%sn" "---FULL ACTUAL---"
cat $TACTUAL
fi
minor_sep
FAIL="1"
fi
fi
if (( FAIL == 0 )); then
printf "OKn"
((NPASS++))
fi
done
printf "Finished:n"
printf "%2d / %2d Normal correctn" "$NPASS" "$NTESTS"
printf "n"
fi
#
15. ===============================================
=================================
# Run valgrind tests: check only for problems identified by
valgrind
if [ "$run_valg" = "1" ]; then
minor_sep
printf "hash_main.c VALGRIND TESTSn"
for i in $all_tests; do
printf "TEST %2d %-18s : " "$i" "${tnames[i]}"
# run code through valgrind
{ printf "%sn" "${input[i]}" | $VALGRIND ./hash_main -
echo ; } >& $VALGOUT
# Check various outputs from valgrind
if ! grep -q 'ERROR SUMMARY: 0 errors from 0 contexts
(suppressed: 0 from 0)' $VALGOUT ||
! grep -q 'in use at exit: 0 bytes in 0 blocks'
$VALGOUT ||
grep -q 'definitely lost: 0 bytes in 0 blocks'
$VALGOUT;
then
printf "FAIL: Valgrind detected problemsn"
minor_sep
cat $VALGOUT
minor_sep
else
printf "Valgrind OKn"
((NVALG++))
fi
done
printf "Finished:n"
printf "%2d / %2d Valgrind correctn" "$NVALG"
"$VTESTS"
16. printf "n"
fi
NVALG=$((NVALG / valg_denom))
VTESTS=$((VTESTS / valg_denom))
major_sep
printf "OVERALL:n"
printf "%2d / %2d Normal correctn" "$NPASS" "$NTESTS"
printf "%2d / %2d Valgrind pointsn" "$NVALG" "$VTESTS"
printf "RESULTS: %d / %d points for normal/valgrind testsn"
"$((NPASS+NVALG))" "$((NTESTS+VTESTS))"
__MACOSX/a1-code/._test_hash_main.sh
a1-code/test-data/README
This directory is for files generated during testing. It must be
present for tests to work but the contents may be safely ignored.
Files in this directory may be safely removed. The provided
Makefile
target
make clean-tests
will do this.
__MACOSX/a1-code/test-data/._README
__MACOSX/a1-code/._test-data
a1-code/test_graph_file.sh
17. #!/bin/bash
#
# tests for graph_file executable, run as one of
# > ./test_graph_file.sh # run everything
# > ./test_graph_file.sh 2 # run only tests 2
# > ./test_graph_file.sh norm # run only normal tests
# > ./test_graph_file.sh valg # run only valgrind tests
# > ./test_graph_file.sh norm 2 # run only normal test 2
# > ./test_graph_file.sh valg 2 # run only vaglgrind test 2
#
# 1 point(s) per 10 normal tests
# 0-3 point(s) penalty for memory problems under Valgrind
function major_sep(){
printf '%sn'
'====================================='
}
function minor_sep(){
printf '%sn' '-------------------------------------'
}
# major_sep
# printf "PROBLEM 2B graph_file.cn"
generate=1
run_norm=1 # run normal tests
run_valg=1 # run valgrind tests
valg_penalty_max=3 # maximum point
deduction for valgrind problems
VALGRIND="valgrind --leak-check=full --show-leak-
kinds=all"
DIFF="diff -bBy" # -b ignore whitespace, -B
ignore blank lines, -y do side-by-side comparison
INPUT=test-data/input.tmp # name for expected
18. output file
EXPECT=test-data/expect.tmp # name for expected
output file
ACTUAL=test-data/actual.tmp # name for actual
output file
DIFFOUT=test-data/testdiff.tmp # name for diff output
file
VALGOUT=test-data/valgrind.tmp # name for valgrind
output file
printf "Loading tests... "
source test_graph_file_data.sh
printf "%d tests loadedn" "$T"
NTESTS=$T
VTESTS=$T
NPASS=0
NVALG=0
all_tests=$(seq $NTESTS)
# Turn off normal/valgrind test sections
case "$1" in
norm)
run_valg=0
shift
;;
valg)
run_norm=0
shift
;;
esac
# Check whether a single test is being run
single_test=$1
if ((single_test > 0 && single_test <= NTESTS)); then
19. printf "Running single TEST %dn" "$single_test"
all_tests=$single_test
NTESTS=1
VTESTS=1
else
printf "Running %d testsn" "$NTESTS"
fi
# printf "tests: %sn" "$all_tests"
printf "n"
# Run normal tests: capture output and check against expected
if [ "$run_norm" = "1" ]; then
minor_sep
printf "graph_file.c NORMAL TESTSn"
for i in $all_tests; do
printf "TEST %2d %-18s : " "$i" "${tnames[i]}"
# Run the test
# generate the input file
printf "%sn" "${input[i]}" | ./save_deltas "${format[i]}"
$INPUT > /dev/null
# run program on input file
{ ./graph_file "${format[i]}" $INPUT "${height[i]}" ; }
>& $ACTUAL
# generate expected output
printf "%sn" "${output[i]}" > $EXPECT
# Check for failure, print side-by-side diff if problems
if ! $DIFF $EXPECT $ACTUAL > $DIFFOUT
then
printf "FAIL: Output Incorrectn"
minor_sep
printf "INPUT:n%sn" "${input[i]}"
printf "OUTPUT: EXPECT vs ACTUALn"
20. cat $DIFFOUT
if [ "$generate" == "1" ]; then
printf "FULL ACTUALn"
cat $ACTUAL
fi
minor_sep
else
printf "OKn"
((NPASS++))
fi
done
printf "Finishedn"
printf "%2d / %2d Normal correctn" "$NPASS" "$NTESTS"
printf "n"
fi
#
===============================================
=================================
# Run valgrind tests: check only for problems identified by
valgrind
if [ "$run_valg" = "1" ]; then
minor_sep
printf "graph_file.c VALGRIND TESTSn"
for i in $all_tests; do
printf "TEST %2d %-18s : " "$i" "${tnames[i]}"
# Run the test
# generate the input file
printf "%sn" "${input[i]}" | ./save_deltas "${format[i]}"
$INPUT > /dev/null
# run code through valgrind
{ $VALGRIND ./graph_file "${format[i]}" $INPUT
21. "${height[i]}" ; } >& $VALGOUT
# Check various outputs from valgrind
if ! grep -q 'ERROR SUMMARY: 0 errors from 0 contexts
(suppressed: 0 from 0)' $VALGOUT ||
! grep -q 'in use at exit: 0 bytes in 0 blocks'
$VALGOUT ||
grep -q 'definitely lost: 0 bytes in 0 blocks'
$VALGOUT;
then
printf "FAIL: Valgrind detected problemsn"
minor_sep
cat $VALGOUT
minor_sep
else
printf "Valgrind OKn"
((NVALG++))
fi
done
printf "Finishedn"
printf "%2d / %2d Valgrind correctn" "$NVALG"
"$VTESTS"
printf "n"
fi
major_sep
printf "OVERALL:n"
printf "%2d / %2d Normal correctn" "$NPASS" "$NTESTS"
printf "%2d / %2d Valgrind correctn" "$NVALG" "$VTESTS"
valg_penalty=$((VTESTS-NVALG))
if ((valg_penalty > valg_penalty_max)); then
valg_penalty=$valg_penalty_max
fi
printf "Valgrind penalty: -%dn" "$valg_penalty"
22. SCORE=$((NPASS-valg_penalty))
if ((SCORE < 0)); then
SCORE=0;
fi
printf "RESULTS: %d / %d points for normal/valgrind testsn"
"$SCORE" "$NTESTS"
__MACOSX/a1-code/._test_graph_file.sh
a1-code/read_deltas.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "deltas.h"
#include <sys/types.h>
#include <sys/stat.h>
int *read_text_deltas(char *fname, int *len){
int num = 0;
int count = 0;
FILE *fp;
fp = fopen(fname,"r");
if(fp == NULL){
*len = -1;
return NULL;
23. }
while(!feof(fp)){
fscanf(fp,"%d", &num);
count++;
}
rewind(fp);
int *arr = (int*) malloc(count * sizeof(int));
int i=1;
fscanf(fp,"%d", &num);
arr[i - 1] = num;
while(!feof(fp)){
fscanf(fp,"%d", &num);
arr[i] = num;
//printf("%d %dn", i,arr[i-1] + num);
arr[i] = arr[i-1] + num;
i++;
}
*len = count - 1;
fclose(fp);
return arr;
}
int *read_int_deltas(char *fname, int *len){
struct stat buf;
int num = 0;
int result = stat(fname, &buf);
27. VALGRIND = valgrind --leak-check=full --show-leak-kinds=all
test : test-p1 test-p2 test-p3
test-p1 : test-p1-norm test-p1-valg
test-p1-norm : test_read_deltas
@printf "===P1 Normal tests for read_deltas() via
test_read_deltas===n"
./test_read_deltas
@printf "n"
test-p1-valg : test_read_deltas
@printf "n"
@printf "===P1 Valgrind tests for read_deltas() via
test_read_deltas===n"
@echo $(VALGRIND) ./test_read_deltas
@$(VALGRIND) ./test_read_deltas >& test-data/p1-
valgrind.tmp
@chmod u+rx ./test_check_valgrind.sh
@./test_check_valgrind.sh 5 'PROBLEM 1 Valgrind
Memory Checks' test-data/p1-valgrind.tmp
@printf "n"
test_read_deltas.o : test_read_deltas.c deltas.h
$(CC) -c $<
test_read_deltas : test_read_deltas.o read_deltas.o
$(CC) -o [email protected] $^
test-p2 : test-p2a test-p2b
test-p2a : print_graph_demo graph_file save_deltas
@printf "===TESTS for P2A===n"
@printf "Testing print_graph() via print_graph_demon"
28. @chmod u+rx ./test_print_graph.sh
./test_print_graph.sh
test-p2b : print_graph_demo graph_file save_deltas
@printf "===TESTS for P2B===n"
@printf "Testing graph_filen"
@chmod u+rx ./test_graph_file.sh
./test_graph_file.sh
test-p3 : hash_main
@printf "===TESTS for P3===n"
@chmod u+rx ./test_hash_main.sh
./test_hash_main.sh
clean-tests :
rm -f test_read_deltas
rm -f test-data/*.tmp test-data/*.tree
__MACOSX/a1-code/._Makefile
a1-code/test_print_graph.sh
#!/bin/bash
#
# tests for print_graph_demo, run as one of
# > ./test_print_graph.sh # run everything
# > ./test_print_graph.sh 2 # run only tests 2
# > ./test_print_graph.sh norm # run only normal tests
# > ./test_print_graph.sh valg # run only valgrind tests
# > ./test_print_graph.sh norm 2 # run only normal test 2
# > ./test_print_graph.sh valg 2 # run only vaglgrind test 2
#
# 4 point(s) for the single normal test
# 1 point(s) for avoiding memory problems under Valgrind
29. function major_sep(){
printf '%sn'
'====================================='
}
function minor_sep(){
printf '%sn' '-------------------------------------'
}
# major_sep
# printf "PROBLEM 2A print_graph_demo.cn"
generate=1
run_norm=1 # run normal tests
run_valg=1 # run valgrind tests
norm_mult=4 # weighting for normal tests
valg_mult=1 # weighting for valgrind tests
VALGRIND="valgrind --leak-check=full --show-leak-
kinds=all"
DIFF="diff -bBy" # -b ignore whitespace, -B
ignore blank lines, -y do side-by-side comparison
INPUT=test-data/input.tmp # name for expected
output file
EXPECT=test-data/expect.tmp # name for expected
output file
ACTUAL=test-data/actual.tmp # name for actual
output file
DIFFOUT=test-data/diff.tmp # name for diff output
file
VALGOUT=test-data/valgrind.tmp # name for valgrind
output file
printf "Loading tests... "
source test_print_graph_data.sh
30. printf "%d tests loadedn" "$T"
NTESTS=$T
VTESTS=$T
NPASS=0
NVALG=0
all_tests=$(seq $NTESTS)
case "$1" in
norm)
run_valg=0
shift
;;
valg)
run_norm=0
shift
;;
esac
# Check whether a single test is being run
single_test=$1
if ((single_test > 0 && single_test <= NTESTS)); then
printf "Running single TEST %dn" "$single_test"
all_tests=$single_test
NTESTS=1
VTESTS=1
else
printf "Running %d testsn" "$NTESTS"
fi
printf "tests: %sn" "$all_tests"
printf "n"
# Run normal tests: capture output and check against expected
31. if [ "$run_norm" = "1" ]; then
minor_sep
printf "print_graph_demo NORMAL TESTSn"
for i in $all_tests; do
printf "TEST %2d %-18s : " "$i" "${tnames[i]}"
# run program on input file
{ ./print_graph_demo ; } >& $ACTUAL
# generate expected output
printf "%sn" "${output[i]}" > $EXPECT
# Check for failure, print side-by-side diff if problems
if ! $DIFF $EXPECT $ACTUAL > $DIFFOUT
then
printf "FAIL: Output Incorrectn"
minor_sep
printf "INPUT:n%sn" "${input[i]}"
printf "OUTPUT: EXPECT vs ACTUALn"
cat $DIFFOUT
if [ "$generate" == "1" ]; then
printf "FULL ACTUALn"
cat $ACTUAL
fi
minor_sep
else
printf "OKn"
((NPASS++))
fi
done
printf "Finishedn"
major_sep
printf "%2d / %2d Normal correctn"
"$((NPASS*norm_mult))" "$((NTESTS*norm_mult))"
printf "n"
32. fi
#
===============================================
=================================
# Run valgrind tests: check only for problems identified by
valgrind
if [ "$run_valg" = "1" ]; then
minor_sep
printf "print_graph_demo VALGRIND TESTSn"
for i in $all_tests; do
printf "TEST %2d %-18s : " "$i" "${tnames[i]}"
# Run the test
# generate the input file
printf "%sn" "${input[i]}" | ./save_deltas "${format[i]}"
$INPUT > /dev/null
# run code through valgrind
{ $VALGRIND ./print_graph_demo ; } >& $VALGOUT
# Check various outputs from valgrind
if ! grep -q 'ERROR SUMMARY: 0 errors from 0 contexts
(suppressed: 0 from 0)' $VALGOUT ||
! grep -q 'in use at exit: 0 bytes in 0 blocks'
$VALGOUT ||
grep -q 'definitely lost: 0 bytes in 0 blocks'
$VALGOUT;
then
printf "FAIL: Valgrind detected problemsn"
minor_sep
cat $VALGOUT
minor_sep
else
printf "Valgrind OKn"
33. ((NVALG++))
fi
done
printf "Finishedn"
major_sep
printf "%2d / %2d Valgrind correctn"
"$((NVALG*valg_mult))" "$((VTESTS*valg_mult))"
printf "n"
fi
NPASS=$((NPASS*norm_mult))
NTESTS=$((NTESTS*norm_mult))
NVALG=$((NVALG*valg_mult))
VTESTS=$((VTESTS*valg_mult))
major_sep
printf "OVERALL:n"
printf "%2d / %2d Normal correctn" "$NPASS" "$NTESTS"
printf "%2d / %2d Valgrind correctn" "$NVALG" "$VTESTS"
printf "RESULTS: %d / %d points for normal/valgrind testsn"
"$((NPASS+NVALG))" "$((NTESTS+VTESTS))"
__MACOSX/a1-code/._test_print_graph.sh
a1-code/hashmap.h
// hashmap.h: header for hashmap problem
#ifndef HASHMAP_H
#define HASHMAP_H 1
// Type for linked list nodes in hash map
typedef struct hashnode {
char key[128]; // string key for items in the map
34. char val[128]; // string value for items in the map
struct hashnode *next; // pointer to next node, NULL if
last node
} hashnode_t;
// Type of hash table
typedef struct {
int item_count; // how many key/val pairs in the table
int table_size; // how big is the table array
hashnode_t **table; // array of pointers to nodes which
contain key/val pairs
} hashmap_t;
#define HASHMAP_DEFAULT_TABLE_SIZE 5 // default size
of table for main application
// functions defined in hash_funcs.c
long hashcode(char key[]);
int next_prime(int num);
void hashmap_init(hashmap_t *hm, int table_size);
int hashmap_put(hashmap_t *hm, char key[], char value[]);
void hashmap_expand(hashmap_t *hm);
char *hashmap_get(hashmap_t *hm, char key[]);
void hashmap_free_table(hashmap_t *hm);
void hashmap_write_items(hashmap_t *hm, FILE *out);
void hashmap_show_structure(hashmap_t *hm);
void hashmap_save(hashmap_t *hm, char *filename);
int hashmap_load(hashmap_t *hm, char *filename);
#endif
__MACOSX/a1-code/._hashmap.h
36. printf("n");
for(val = max_element; val >= 0; val -= units_per_height){
printf("%4d |" , (int)val);
for(j = 0; j < len; j++){
if(data[j] >= val)
printf("X");
else
printf(" ");
}
printf("n");
}
printf("%6c");
for(i = 0; i < len; i++){
if(i%5 == 0)
printf("+");
else
printf("-");
}
printf("n%6c");
for(i = 0; i < len; i+=5){
printf("%-5d", i);
}
printf("n");
}
__MACOSX/a1-code/._print_graph.c
a1-code/test_hash_main_data.sh
#!/bin/bash
T=0 # global test number
37. ((T++))
tnames[T]="start-print-quit"
read -r -d '' input[$T] <<"ENDIN"
print
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> print
HM> quit
ENDOUT
((T++))
38. tnames[T]="hashcode-get-empty"
read -r -d '' input[$T] <<"ENDIN"
print
hashcode a
hashcode A
hashcode Aa
hashcode apple
hashcode banana
get a
get Aa
get apple
get banana
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
39. load factor
quit : exit the program
HM> print
HM> hashcode a
97
HM> hashcode A
65
HM> hashcode Aa
24897
HM> hashcode apple
1819308129
HM> hashcode banana
1634623842
HM> get a
NOT FOUND
HM> get Aa
NOT FOUND
HM> get apple
NOT FOUND
HM> get banana
NOT FOUND
HM> quit
ENDOUT
((T++))
tnames[T]="get-single"
read -r -d '' input[$T] <<"ENDIN"
print
put apple fruit
get apple
get banana
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
40. Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> print
HM> put apple fruit
HM> get apple
FOUND: fruit
HM> get banana
NOT FOUND
HM> quit
ENDOUT
((T++))
tnames[T]="put3"
read -r -d '' input[$T] <<"ENDIN"
put Kyle alive
put Kenny dead
41. put Stan alive
print
get Kyle
get Kenny
get Stan
get Cartman
get Token
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> put Kyle alive
HM> put Kenny dead
HM> put Stan alive
42. HM> print
Kyle : alive
Stan : alive
Kenny : dead
HM> get Kyle
FOUND: alive
HM> get Kenny
FOUND: dead
HM> get Stan
FOUND: alive
HM> get Cartman
NOT FOUND
HM> get Token
NOT FOUND
HM> quit
ENDOUT
((T++))
tnames[T]="put-collisions"
read -r -d '' input[$T] <<"ENDIN"
put B 1
put D 2
put N 3
print
get B
get D
get N
get C
get I
put A 4
put C 5
put I 6
put X 7
put W 8
print
get A
43. get B
get C
get D
get E
get I
get X
get W
get Z
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> put B 1
HM> put D 2
44. HM> put N 3
HM> print
B : 1
D : 2
N : 3
HM> get B
FOUND: 1
HM> get D
FOUND: 2
HM> get N
FOUND: 3
HM> get C
NOT FOUND
HM> get I
NOT FOUND
HM> put A 4
HM> put C 5
HM> put I 6
HM> put X 7
HM> put W 8
HM> print
A : 4
B : 1
C : 5
W : 8
D : 2
N : 3
I : 6
X : 7
HM> get A
FOUND: 4
HM> get B
FOUND: 1
HM> get C
FOUND: 5
HM> get D
45. FOUND: 2
HM> get E
NOT FOUND
HM> get I
FOUND: 6
HM> get X
FOUND: 7
HM> get W
FOUND: 8
HM> get Z
NOT FOUND
HM> quit
ENDOUT
((T++))
tnames[T]="put3-structure"
read -r -d '' input[$T] <<"ENDIN"
put B 1
put D 2
put N 3
print
get B
get D
get N
get C
get I
structure
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
46. overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> put B 1
HM> put D 2
HM> put N 3
HM> print
B : 1
D : 2
N : 3
HM> get B
FOUND: 1
HM> get D
FOUND: 2
HM> get N
FOUND: 3
HM> get C
NOT FOUND
HM> get I
NOT FOUND
HM> structure
item_count: 3
47. table_size: 5
load_factor: 0.6000
0 :
1 : {(66) B : 1}
2 :
3 : {(68) D : 2} {(78) N : 3}
4 :
HM> quit
ENDOUT
((T++))
tnames[T]="put-overwrite"
read -r -d '' input[$T] <<"ENDIN"
put B 1
put D 2
put N 3
put A 4
put C 5
put I 6
put X 7
put W 8
structure
put B 11
put I 66
put A 44
put W 88
structure
get B
get D
get I
get W
get X
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
48. Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> put B 1
HM> put D 2
HM> put N 3
HM> put A 4
HM> put C 5
HM> put I 6
HM> put X 7
HM> put W 8
HM> structure
item_count: 8
table_size: 5
load_factor: 1.6000
0 : {(65) A : 4}
1 : {(66) B : 1}
49. 2 : {(67) C : 5} {(87) W : 8}
3 : {(68) D : 2} {(78) N : 3} {(73) I : 6} {(88) X : 7}
4 :
HM> put B 11
Overwriting previous key/val
HM> put I 66
Overwriting previous key/val
HM> put A 44
Overwriting previous key/val
HM> put W 88
Overwriting previous key/val
HM> structure
item_count: 8
table_size: 5
load_factor: 1.6000
0 : {(65) A : 44}
1 : {(66) B : 11}
2 : {(67) C : 5} {(87) W : 88}
3 : {(68) D : 2} {(78) N : 3} {(73) I : 66} {(88) X : 7}
4 :
HM> get B
FOUND: 11
HM> get D
FOUND: 2
HM> get I
FOUND: 66
HM> get W
FOUND: 88
HM> get X
FOUND: 7
HM> quit
ENDOUT
((T++))
tnames[T]="larger-structure"
read -r -d '' input[$T] <<"ENDIN"
50. put Kyle alive
put Kenny dead
put Stan alive
print
structure
put Cartman jerk
put Timmy TIMMY!
put MrGarrison odd
put MrHat very-odd
put Butters lovable
put Chef disavowed
print
structure
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
51. expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> put Kyle alive
HM> put Kenny dead
HM> put Stan alive
HM> print
Kyle : alive
Stan : alive
Kenny : dead
HM> structure
item_count: 3
table_size: 5
load_factor: 0.6000
0 : {(1701607755) Kyle : alive}
1 : {(1851880531) Stan : alive}
2 : {(521543771467) Kenny : dead}
3 :
4 :
HM> put Cartman jerk
HM> put Timmy TIMMY!
HM> put MrGarrison odd
HM> put MrHat very-odd
HM> put Butters lovable
HM> put Chef disavowed
HM> print
Kyle : alive
Cartman : jerk
Butters : lovable
Stan : alive
MrHat : very-odd
Kenny : dead
MrGarrison : odd
Timmy : TIMMY!
Chef : disavowed
HM> structure
52. item_count: 9
table_size: 5
load_factor: 1.8000
0 : {(1701607755) Kyle : alive} {(31069370171154755)
Cartman : jerk} {(32495402392778050) Butters : lovable}
1 : {(1851880531) Stan : alive} {(499848344141) MrHat :
very-odd}
2 : {(521543771467) Kenny : dead} {(8316304022500241997)
MrGarrison : odd}
3 : {(521526929748) Timmy : TIMMY!}
4 : {(1717921859) Chef : disavowed}
HM> quit
ENDOUT
((T++))
tnames[T]="put3-EOF"
read -r -d '' input[$T] <<"ENDIN"
put Kyle alive
put Kenny dead
put Stan alive
print
get Kyle
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
53. clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> put Kyle alive
HM> put Kenny dead
HM> put Stan alive
HM> print
Kyle : alive
Stan : alive
Kenny : dead
HM> get Kyle
FOUND: alive
HM>
ENDOUT
((T++))
tnames[T]="clear-put-clear"
read -r -d '' input[$T] <<"ENDIN"
clear
print
structure
put Kyle alive
put Kenny dead
put Stan alive
put Cartman jerk
print
structure
clear
54. print
structure
put Timmy TIMMY!
put MrGarrison odd
put MrHat very-odd
put Butters lovable
put Chef disavowed
print
structure
clear
print
structure
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
55. quit : exit the program
HM> clear
HM> print
HM> structure
item_count: 0
table_size: 5
load_factor: 0.0000
0 :
1 :
2 :
3 :
4 :
HM> put Kyle alive
HM> put Kenny dead
HM> put Stan alive
HM> put Cartman jerk
HM> print
Kyle : alive
Cartman : jerk
Stan : alive
Kenny : dead
HM> structure
item_count: 4
table_size: 5
load_factor: 0.8000
0 : {(1701607755) Kyle : alive} {(31069370171154755)
Cartman : jerk}
1 : {(1851880531) Stan : alive}
2 : {(521543771467) Kenny : dead}
3 :
4 :
HM> clear
HM> print
HM> structure
item_count: 0
table_size: 5
57. 4 :
HM>
ENDOUT
((T++))
tnames[T]="put3-save"
read -r -d '' input[$T] <<"ENDIN"
put A 1
put E 2
put C 3
put D 4
save test-data/put3.tmp
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
58. load factor
quit : exit the program
HM> put A 1
HM> put E 2
HM> put C 3
HM> put D 4
HM> save test-data/put3.tmp
HM> quit
ENDOUT
#
tfiles[T]="test-data/put3.tmp"
read -r -d '' tfiles_expect[$T] <<"ENDOUT"
5 4
A : 1
C : 3
D : 4
E : 2
ENDOUT
((T++))
tnames[T]="put-many-save"
read -r -d '' input[$T] <<"ENDIN"
put Kyle alive
put Kenny dead
put Stan alive
put Cartman jerk
put Timmy TIMMY!
put MrGarrison odd
put MrHat very-odd
put Butters lovable
put Chef disavowed
print
structure
save test-data/put-many.tmp
ENDIN
#
59. read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> put Kyle alive
HM> put Kenny dead
HM> put Stan alive
HM> put Cartman jerk
HM> put Timmy TIMMY!
HM> put MrGarrison odd
HM> put MrHat very-odd
HM> put Butters lovable
HM> put Chef disavowed
HM> print
Kyle : alive
Cartman : jerk
Butters : lovable
61. ((T++))
tnames[T]="save-load"
read -r -d '' input[$T] <<"ENDIN"
put A 1
put E 2
put C 3
put D 4
save test-data/save-load.tmp
clear
print
load test-data/save-load.tmp
print
structure
get E
get R
get A
put R 5
put S 6
print structure
get R
get S
load test-data/save-load.tmp
print
structure
get R
get S
load test-data/not-there.tmp
print
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
62. put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> put A 1
HM> put E 2
HM> put C 3
HM> put D 4
HM> save test-data/save-load.tmp
HM> clear
HM> print
HM> load test-data/save-load.tmp
HM> print
A : 1
C : 3
D : 4
E : 2
HM> structure
item_count: 4
table_size: 5
load_factor: 0.8000
0 : {(65) A : 1}
63. 1 :
2 : {(67) C : 3}
3 : {(68) D : 4}
4 : {(69) E : 2}
HM> get E
FOUND: 2
HM> get R
NOT FOUND
HM> get A
FOUND: 1
HM> put R 5
HM> put S 6
HM> print
A : 1
C : 3
R : 5
D : 4
S : 6
E : 2
HM> structure
item_count: 6
table_size: 5
load_factor: 1.2000
0 : {(65) A : 1}
1 :
2 : {(67) C : 3} {(82) R : 5}
3 : {(68) D : 4} {(83) S : 6}
4 : {(69) E : 2}
HM> get R
FOUND: 5
HM> get S
FOUND: 6
HM> load test-data/save-load.tmp
HM> print
A : 1
C : 3
64. D : 4
E : 2
HM> structure
item_count: 4
table_size: 5
load_factor: 0.8000
0 : {(65) A : 1}
1 :
2 : {(67) C : 3}
3 : {(68) D : 4}
4 : {(69) E : 2}
HM> get R
NOT FOUND
HM> get S
NOT FOUND
HM> load test-data/not-there.tmp
ERROR: could not open file 'test-data/not-there.tmp'
load failed
HM> print
A : 1
C : 3
D : 4
E : 2
HM> quit
ENDOUT
#
tfiles[T]="test-data/save-load.tmp"
read -r -d '' tfiles_expect[$T] <<"ENDOUT"
5 4
A : 1
C : 3
D : 4
E : 2
ENDOUT
65. ((T++))
tnames[T]="prime-expand"
read -r -d '' input[$T] <<"ENDIN"
next_prime 5
next_prime 6
next_prime 10
next_prime 25
next_prime 1024
put A 1
put B 2
put C 3
put D 4
put E 5
put F 6
put G 7
print
structure
expand
print
structure
expand
print
structure
clear
put Kyle alive
put Kenny dead
put Stan alive
put Cartman jerk
put Timmy TIMMY!
put MrGarrison odd
put MrHat very-odd
put Butters lovable
put Chef disavowed
print
structure
expand
66. print
structure
put Token dude
put Wendy gal
put Jimmy crutches
put Damien evil
put Santa bad
put Jesus good
put Marvin starvin
print
structure
expand
print
structure
expand
print
structure
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
67. in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> next_prime 5
5
HM> next_prime 6
7
HM> next_prime 10
11
HM> next_prime 25
29
HM> next_prime 1024
1031
HM> put A 1
HM> put B 2
HM> put C 3
HM> put D 4
HM> put E 5
HM> put F 6
HM> put G 7
HM> print
A : 1
F : 6
B : 2
G : 7
C : 3
D : 4
E : 5
HM> structure
item_count: 7
table_size: 5
load_factor: 1.4000
0 : {(65) A : 1} {(70) F : 6}
68. 1 : {(66) B : 2} {(71) G : 7}
2 : {(67) C : 3}
3 : {(68) D : 4}
4 : {(69) E : 5}
HM> expand
HM> print
B : 2
C : 3
D : 4
E : 5
F : 6
G : 7
A : 1
HM> structure
item_count: 7
table_size: 11
load_factor: 0.6364
0 : {(66) B : 2}
1 : {(67) C : 3}
2 : {(68) D : 4}
3 : {(69) E : 5}
4 : {(70) F : 6}
5 : {(71) G : 7}
6 :
7 :
8 :
9 :
10 : {(65) A : 1}
HM> expand
HM> print
E : 5
F : 6
G : 7
A : 1
B : 2
C : 3
69. D : 4
HM> structure
item_count: 7
table_size: 23
load_factor: 0.3043
0 : {(69) E : 5}
1 : {(70) F : 6}
2 : {(71) G : 7}
3 :
4 :
5 :
6 :
7 :
8 :
9 :
10 :
11 :
12 :
13 :
14 :
15 :
16 :
17 :
18 :
19 : {(65) A : 1}
20 : {(66) B : 2}
21 : {(67) C : 3}
22 : {(68) D : 4}
HM> clear
HM> put Kyle alive
HM> put Kenny dead
HM> put Stan alive
HM> put Cartman jerk
HM> put Timmy TIMMY!
HM> put MrGarrison odd
HM> put MrHat very-odd
76. HM>
ENDOUT
((T++))
tnames[T]="stress"
read -r -d '' input[$T] <<"ENDIN"
put Kyle alive
put Kenny dead
put Stan alive
put Cartman jerk
put Timmy TIMMY!
put MrGarrison odd
put MrHat very-odd
put Butters lovable
put Chef disavowed
structure
expand
structure
save test-data/stress1.tmp
put Token dude
put Wendy gal
put Jimmy crutches
put Damien evil
put Santa bad
put Jesus good
put Marvin starvin
put Kenny ALIVE
put MrHat MrStick
structure
expand
expand
structure
save test-data/stress2.tmp
load test-data/stress1.tmp
structure
77. get Santa
get Marvin
get Cartman
get MrHat
put Syndney Portier
put Robert Smith
expand
expand
expand
structure
get Cartman
get Robert
save test-data/stress3.tmp
load test-data/stress2.tmp
print
structure
get MrGarrison
get MrHat
get Kenny
get Santa
get Wendy
get Marvin
get Sydney
put Kenny dead
load test-data/stress3.tmp
get Kenny
structure
expand
structure
quit
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Hashmap Demo
Commands:
hashcode <key> : prints out the numeric hash code for the
78. given key (does not change the hash map)
put <key> <val> : inserts the given key/val into the hash map,
overwrites existing values if present
get <key> : prints the value associated with the given key
or NOT FOUND
print : shows contents of the hashmap ordered by how
they appear in the table
structure : prints detailed structure of the hash map
clear : reinitializes hash map to be empty with default
size
save <file> : writes the contents of the hash map the given
file
load <file> : clears the current hash map and loads the one
in the given file
next_prime <int> : if <int> is prime, prints it, otherwise finds
the next prime and prints it
expand : expands memory size of hashmap to reduce its
load factor
quit : exit the program
HM> put Kyle alive
HM> put Kenny dead
HM> put Stan alive
HM> put Cartman jerk
HM> put Timmy TIMMY!
HM> put MrGarrison odd
HM> put MrHat very-odd
HM> put Butters lovable
HM> put Chef disavowed
HM> structure
item_count: 9
table_size: 5
load_factor: 1.8000
0 : {(1701607755) Kyle : alive} {(31069370171154755)
Cartman : jerk} {(32495402392778050) Butters : lovable}
1 : {(1851880531) Stan : alive} {(499848344141) MrHat :
very-odd}
79. 2 : {(521543771467) Kenny : dead} {(8316304022500241997)
MrGarrison : odd}
3 : {(521526929748) Timmy : TIMMY!}
4 : {(1717921859) Chef : disavowed}
HM> expand
HM> structure
item_count: 9
table_size: 11
load_factor: 0.8182
0 : {(31069370171154755) Cartman : jerk}
{(32495402392778050) Butters : lovable} {(521526929748)
Timmy : TIMMY!}
1 : {(1701607755) Kyle : alive}
2 :
3 : {(499848344141) MrHat : very-odd}
4 : {(521543771467) Kenny : dead}
5 : {(1717921859) Chef : disavowed}
6 : {(1851880531) Stan : alive}
7 :
8 :
9 : {(8316304022500241997) MrGarrison : odd}
10 :
HM> save test-data/stress1.tmp
HM> put Token dude
HM> put Wendy gal
HM> put Jimmy crutches
HM> put Damien evil
HM> put Santa bad
HM> put Jesus good
HM> put Marvin starvin
HM> put Kenny ALIVE
Overwriting previous key/val
HM> put MrHat MrStick
Overwriting previous key/val
HM> structure
item_count: 16
97. a1-code/save_deltas.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "deltas.h"
#define MODE_TEXT 1
#define MODE_INT 2
#define MODE_4BIT 3
int main(int argc, char *argv[]){
if(argc < 3){
printf("usage: %s <format> <filename>n",argv[0]);
printf("reads input from stdin and outputs in given format to
<filename>n");
printf("if typing numbers in, press Ctrl-D to end inputn");
printf(" <format> is one ofn");
printf(" text : text ints are in the given filenamen");
printf(" int : binary ints are in the given filenamen");
printf(" 4bit : 4bit binary ints are in the given filenamen");
return 1;
}
char *format = argv[1];
char *fname = argv[2];
int mode = -1;
if( strcmp("text", format)==0 ){
mode = MODE_TEXT;
}
else if( strcmp("int", format)==0 ){
mode = MODE_INT;
}
else if( strcmp("4bit", format)==0 ){
mode = MODE_4BIT;
}
else{
98. printf("Unknown format '%s'n",format);
return 1;
}
FILE *fout = fopen(fname,"w");
int curr, prev;
int result = fscanf(stdin,"%d",&curr); // handle first number
if(result == EOF){
fclose(fout);
printf("error: no numbers givenn");
return 1;
}
if(mode == MODE_TEXT){
fprintf(fout,"%d ",curr);
}
else if(mode == MODE_INT || mode == MODE_4BIT ){
fwrite(&curr,sizeof(int),1,fout);
}
int count = 1;
prev=curr;
while(fscanf(stdin,"%d",&curr) != EOF){
if(mode == MODE_TEXT){
int delta = curr - prev;
fprintf(fout,"%d ",delta);
prev = curr;
count++;
}
else if(mode == MODE_INT){
int delta = curr - prev;
fwrite(&delta,sizeof(int),1,fout);
prev = curr;
count++;
}
else if(mode == MODE_4BIT){
100. a1-code/make
a1-code/read_deltas.o
a1-code/graph_main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "deltas.h"
#include <sys/types.h>
#include <sys/stat.h>
int main(int argc, char const *argv[]) {
if(argc < 3){
printf("usage: %s <format> <filename>n",argv[0]);
printf(" <format> is one ofn");
printf(" text : text ints are in the given filenamen");
printf(" int : binary ints are in the given filenamen");
printf(" 4bit : 4bit binary ints are in the given filenamen");
return 1;
}
char *format = argv[1];
char *fname = argv[2];
111. 13 12 9 18 67 79 39 61 83 52 72 34 63 44 5 14 51 14 49 91 24
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Reading text format
length: 128
min: 2
max: 98
range: 96
max_height: 14
units_per_height: 6.86
+----+----+----+----+----+----+----+----+----+----+----+----+--
--+----+----+----+----+----+----+----+----+----+----+----+----+--
98 |
X
91 | X X XX X X X
X X X
84 | X X X X X X XXX X X XX
X X X X X X X X X
77 | X X X X XX X X X X XXX X XX XX
X X XX X X XX X X X XX X X X
70 | X X X X X XX X XX X X XXX XXXXXX
XX X XX X XX XX X XX X X X X XX X X
X X
63 | X X X X X XX X XX X X XXX XXXXXX
XXX X X XX X XX XXXX XX X X X X XX
XX X X X X
56 | X XXXX X X XX X XX XXXX XXX XXXXXX
XXXX X X XX X XX XX XXXX XX X X X X XX
XX XX X X X
50 | X XXXX X X XXX XX XX XXXX XXX
XXXXXXX XXXX X X X XX X XX XX XXXX XX X
X X X XX XX XXXX X X X
43 | X XXXX X X XXX XX XXX XXXX X XXX
XXXXXXX XXXX X X X XX XXXX XX X X XXXXX
XXXX XXX X XX XX XXXX XX X XX
112. 36 | X XXXXX XX X XXX X XX XXXX XXXX X XXX
XXXXXXXXXXXX X X XXX XX XXXX XX XX X
XXXXX XXXXXXXXXX XXX XXXXXXX XX X XX
29 | X XXXXX XX X XXX X XX X XXXX XXXX X XXX
XXXXXXXXXXXX XXX XXX XX XXXX XXXXX X
XXXXX XXXXXXXXXX XXX XXXXXXXXXX X XX
22 | XXXXXXX XXXX XXX X XX X XXXX XXXXX X
XXX XXXXXXXXXXXX XXX XXX XXX XXXXXXXXXXX
X XXXXX XXXXXXXXXXX XXX XXXXXXXXXX X
XXX
15 |X XXXXXXXXXXXXXXXXXXX XXXX XXXX XXXXX
X XXXXXXXXXXXXXXXXX XXX XXX XXX
XXXXXXXXXXX X XXXXXX XXXXXXXXXXX XXX
XXXXXXXXXXX X XXX
8 |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX XXX XXX
XXXXXXXXXXXXXXXXX XXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXX
2
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXX
+----+----+----+----+----+----+----+----+----+----+----+----+--
--+----+----+----+----+----+----+----+----+----+----+----+----+--
0 5 10 15 20 25 30 35 40 45 50 55 60 65
70 75 80 85 90 95 100 105 110 115 120 125
ENDOUT
((T++))
tnames[T]="int-rand-32"
format[T]="text"
height[T]="32"
read -r -d '' input[$T] <<"ENDIN"
18 9 84 26 41 90 60 61 78 17 71 38 24 83 18 53 85 79 21 36 16
14 52 95 21 34 11 42 95 71 49 7 58 77 62 84 24 14 47 8 87 94
113. 96 17 55 75 89 73 79 94 76 37 59 66 86 92 15 7 75 30 67 7 5 42
55 39 2 75 81 26 14 59 48 59 89 25 96 77 35 36 46 26 8 47 7 15
47 98 75 67 90 5 83 85 43 90 40 94 43 84 38 75 22 13 37 77 83
13 12 9 18 67 79 39 61 83 52 72 34 63 44 5 14 51 14 49 91 24
ENDIN
#
read -r -d '' output[$T] <<"ENDOUT"
Reading text format
length: 128
min: 2
max: 98
range: 96
max_height: 32
units_per_height: 3.00
+----+----+----+----+----+----+----+----+----+----+----+----+--
--+----+----+----+----+----+----+----+----+----+----+----+----+--
98 |
X
95 | X X X X
X
92 | X X XX X X X
X X
89 | X X X XX X X X X
X X X X X X
86 | X X X XXX X X XX
X X X X X X X
83 | X X X X X X X XXX X X XX
X X X X XX X X X X X X
80 | X X X X X X X XXX X X XX
X X X X X XX X X X X X X
77 | X X X X XX X X X X XXX X XX XX
X X XX X X XX X X X XX X X X
74 | X X X X XX X X X X XXX XX XXX XX
X XX X XX XX X XX X X X X XX X X
X
71 | X X X X X XX X XX X X XXX XXXXXX
114. XX X XX X XX XX X XX X X X X XX X X
X X
68 | X X X X X XX X XX X X XXX XXXXXX
XX X XX X XX XX X XX X X X X XX X X
X X
65 | X X X X X XX X XX X X XXX XXXXXX
XXX X X XX X XX XXXX XX X X X X XX
XX X X X
62 | X X X X X XX X XX XXX XXX XXXXXX
XXX X X XX X XX XXXX XX X X X X XX
XX X X X X
59 | X XXXX X X XX X XX XXX XXX XXXXXX
XXXX X X XX X XX XX XXXX XX X X X X XX
XX XX X X X
56 | X XXXX X X XX X XX XXXX XXX XXXXXX
XXXX X X XX X XX XX XXXX XX X X X X XX
XX XX X X X
53 | X XXXX X X XXX X XX XXXX XXX
XXXXXXX XXXX X X X XX X XX XX XXXX XX X
X X X XX XX XX X X X
50 | X XXXX X X XXX XX XX XXXX XXX
XXXXXXX XXXX X X X XX X XX XX XXXX XX X
X X X XX XX XXXX X X X
47 | X XXXX X X XXX XX XXX XXXX X XXX
XXXXXXX XXXX X X X XX XXXX XX X XXXXX XX
X X X X XX XX XXXX X X XX
44 | X XXXX X X XXX XX XXX XXXX X XXX
XXXXXXX XXXX X X X XX XXXX XX X X XXXXX
XX X X X X XX XX XXXX XX X XX
41 | X XXXXX X X XXX XX XXXX XXXX X XXX
XXXXXXX XXXX X X XX XX XXXX XX X X XXXXX
XXXX XXX X XX XX XXXX XX X XX
38 | X XXXXX XX X XXX XX XXXX XXXX X XXX
XXXXXXX XXXX X X XXX XX XXXX XX X X XXXXX
XXXXXXXXXX XX XXXXXXX XX X XX
35 | X XXXXX XX X XXX X XX XXXX XXXX X XXX
115. XXXXXXXXXXXX X X XXX XX XXXX XXXXX X
XXXXX XXXXXXXXXX XXX XXXXXXX XX X XX
32 | X XXXXX XX X XXX X XX X XXXX XXXX X XXX
XXXXXXXXXXXX X X XXX XX XXXX XXXXX X
XXXXX XXXXXXXXXX XXX XXXXXXXXXX X XX
29 | X XXXXX XX X XXX X XX X XXXX XXXX X XXX
XXXXXXXXXXXX XXX XXX XX XXXX XXXXX X
XXXXX XXXXXXXXXX XXX XXXXXXXXXX X XX
26 | XXXXXXX XX X XXX X XX X XXXX XXXX X XXX
XXXXXXXXXXXX XXX XXX XXX XXXX XXXXXX X
XXXXX XXXXXXXXXX XXX XXXXXXXXXX X XX
23 | XXXXXXX XXXX XXX X XX X XXXX XXXXX X
XXX XXXXXXXXXXXX XXX XXX XXX XXXXXXXXXXX
X XXXXX XXXXXXXXXX XXX XXXXXXXXXX X XXX
20 | XXXXXXX XXXX XXXXX XXXX XXXX XXXXX X
XXX XXXXXXXXXXXX XXX XXX XXX XXXXXXXXXXX
X XXXXX XXXXXXXXXXX XXX XXXXXXXXXX X
XXX
17 |X XXXXXXXXXXXXXXXXXX XXXX XXXX XXXXX X
XXXXXXXXXXXXXXXX XXX XXX XXX
XXXXXXXXXXX X XXXXX XXXXXXXXXXX XXX
XXXXXXXXXXX X XXX
14 |X XXXXXXXXXXXXXXXXXXXXXXXX XXXX
XXXXXXX XXXXXXXXXXXXXXXXX XXX XXX
XXXXXXXXXXXXXXX X XXXXXX XXXXXXXXXXX XXX
XXXXXXXXXXX XXXXXX
11 |X XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXX XXXXXXXXXXXXXXXXX XXX XXX
XXXXXXXXXXXXXXX X XXXXXX
XXXXXXXXXXXXXXXXX XXXXXXXXXXX XXXXXX
8 |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX XXX XXX
XXXXXXXXXXXXXXXXX XXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXX
5
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
123. __MACOSX/a1-code/data/._names.txt
a1-code/data/big.script
put Mary girl
put James boy
put Patricia girl
put John boy
put Jennifer girl
put Robert boy
put Elizabeth girl
put Michael boy
put Linda girl
put William boy
put Barbara girl
put David boy
put Susan girl
put Richard boy
put Jessica girl
put Joseph boy
put Margaret girl
put Thomas boy
put Sarah girl
put Charles boy
put Karen girl
put Christopher boy
put Nancy girl
put Daniel boy
put Betty girl
put Matthew boy
put Lisa girl
put Anthony boy
put Dorothy girl
put Donald boy
put Sandra girl
put Mark boy
put Ashley girl
124. put Paul boy
put Kimberly girl
put Steven boy
put Donna girl
put Andrew boy
put Carol girl
put Kenneth boy
put Michelle girl
put George boy
put Emily girl
put Joshua boy
put Amanda girl
put Kevin boy
put Helen girl
put Brian boy
put Melissa girl
put Edward boy
put Deborah girl
put Ronald boy
put Stephanie girl
put Timothy boy
put Laura girl
put Jason boy
put Rebecca girl
put Jeffrey boy
put Sharon girl
put Ryan boy
put Cynthia girl
put Gary boy
put Kathleen girl
put Jacob boy
put Amy girl
put Nicholas boy
put Shirley girl
put Eric boy
put Anna girl
125. put Stephen boy
put Angela girl
put Jonathan boy
put Ruth girl
put Larry boy
put Brenda girl
put Justin boy
put Pamela girl
put Scott boy
put Nicole girl
put Frank boy
put Katherine girl
put Brandon boy
put Virginia girl
put Raymond boy
put Catherine girl
put Gregory boy
put Christine girl
put Benjamin boy
put Samantha girl
put Samuel boy
put Debra girl
put Patrick boy
put Janet girl
put Alexander boy
put Rachel girl
put Jack boy
put Carolyn girl
put Dennis boy
put Emma girl
put Jerry boy
put Maria girl
put Tyler boy
put Heather girl
put Aaron boy
put Diane girl
126. put Henry boy
put Julie girl
put Douglas boy
put Joyce girl
put Jose boy
put Evelyn girl
put Peter boy
put Frances girl
put Adam boy
put Joan girl
put Zachary boy
put Christina girl
put Nathan boy
put Kelly girl
put Walter boy
put Victoria girl
put Harold boy
put Lauren girl
put Kyle boy
put Martha girl
put Carl boy
put Judith girl
put Arthur boy
put Cheryl girl
put Gerald boy
put Megan girl
put Roger boy
put Andrea girl
put Keith boy
put Ann girl
put Jeremy boy
put Alice girl
put Terry boy
put Jean girl
put Lawrence boy
put Doris girl
127. put Sean boy
put Jacqueline girl
put Christian boy
put Kathryn girl
put Albert boy
put Hannah girl
put Joe boy
put Olivia girl
put Ethan boy
put Gloria girl
put Austin boy
put Marie girl
put Jesse boy
put Teresa girl
put Willie boy
put Sara girl
put Billy boy
put Janice girl
put Bryan boy
put Julia girl
put Bruce boy
put Grace girl
put Jordan boy
put Judy girl
put Ralph boy
put Theresa girl
put Roy boy
put Rose girl
put Noah boy
put Beverly girl
put Dylan boy
put Denise girl
put Eugene boy
put Marilyn girl
put Wayne boy
put Amber girl
128. put Alan boy
put Madison girl
put Juan boy
put Danielle girl
put Louis boy
put Brittany girl
put Russell boy
put Diana girl
put Gabriel boy
put Abigail girl
put Randy boy
put Jane girl
put Philip boy
put Natalie girl
put Harry boy
put Lori girl
put Vincent boy
put Tiffany girl
put Bobby boy
put Alexis girl
put Johnny boy
put Kayla girl
put Logan boy
expand
expand
expand
expand
structure
save big.hm
__MACOSX/a1-code/data/._big.script
a1-code/data/hash-demo.script~
add Lucas
add Mike
129. add Dustin
add Will
add El
print
preorder
find Mike
find Nancy
add Nancy
print
find Max
add Max
print
find Barb
add Barb
print
save stranger.tree
clear
print
add Demigorgon
print
load stranger.tree
preorder
add Jim
add Joyce
print
load stranger.tree
print
quit
__MACOSX/a1-code/data/._hash-demo.script~
a1-code/data/other.script
put Lucas brash
put Mike DM
put Dustin corny
130. put Will lost
print
get Dustin
get El
get Lucas
get Jim
put El weird
put Steve hairy
put Nancy torn
put Barb ran-away?
print
hashcode Lucas
hashcode Barb
structure
expand
structure
save stranger.hm
clear
print
structure
put Jim cop
put Joyce worried
print
structure
get Dustin
get Joyce
load stranger.hm
print
structure
get Dustin
get Joyce
put Will found
put Nancy decided
put Mike girl-crazy
print
structure
131. next_prime 10
next_prime 25
expand
structure
put Jim cop
put Joyce worried
put Erica capitalist
put Barb gone
put Max gamer
put Robin clever
save data/other.hm
quit
__MACOSX/a1-code/data/._other.script
a1-code/data/short.txt
20
-2
-4
-4
-3
-5
1
-2
4
4
-4
2
-0
-2
-0
0
2
1
132. -5
4
-3
__MACOSX/a1-code/data/._short.txt
a1-code/data/other.hm
23 8
El : weird
Barb : ran-away?
Lucas : brash
Dustin : corny
Nancy : decided
Mike : girl-crazy
Steve : hairy
Will : found
__MACOSX/a1-code/data/._other.hm
a1-code/data/big.script~
put Mary girl
put James boy
put Patricia girl
put John boy
put Jennifer girl
put Robert boy
put Elizabeth girl
put Michael boy
put Linda girl
put William boy
put Barbara girl
put David boy
put Susan girl
put Richard boy
133. put Jessica girl
put Joseph boy
put Margaret girl
put Thomas boy
put Sarah girl
put Charles boy
put Karen girl
put Christopher boy
put Nancy girl
put Daniel boy
put Betty girl
put Matthew boy
put Lisa girl
put Anthony boy
put Dorothy girl
put Donald boy
put Sandra girl
put Mark boy
put Ashley girl
put Paul boy
put Kimberly girl
put Steven boy
put Donna girl
put Andrew boy
put Carol girl
put Kenneth boy
put Michelle girl
put George boy
put Emily girl
put Joshua boy
put Amanda girl
put Kevin boy
put Helen girl
put Brian boy
put Melissa girl
put Edward boy
134. put Deborah girl
put Ronald boy
put Stephanie girl
put Timothy boy
put Laura girl
put Jason boy
put Rebecca girl
put Jeffrey boy
put Sharon girl
put Ryan boy
put Cynthia girl
put Gary boy
put Kathleen girl
put Jacob boy
put Amy girl
put Nicholas boy
put Shirley girl
put Eric boy
put Anna girl
put Stephen boy
put Angela girl
put Jonathan boy
put Ruth girl
put Larry boy
put Brenda girl
put Justin boy
put Pamela girl
put Scott boy
put Nicole girl
put Frank boy
put Katherine girl
put Brandon boy
put Virginia girl
put Raymond boy
put Catherine girl
put Gregory boy
135. put Christine girl
put Benjamin boy
put Samantha girl
put Samuel boy
put Debra girl
put Patrick boy
put Janet girl
put Alexander boy
put Rachel girl
put Jack boy
put Carolyn girl
put Dennis boy
put Emma girl
put Jerry boy
put Maria girl
put Tyler boy
put Heather girl
put Aaron boy
put Diane girl
put Henry boy
put Julie girl
put Douglas boy
put Joyce girl
put Jose boy
put Evelyn girl
put Peter boy
put Frances girl
put Adam boy
put Joan girl
put Zachary boy
put Christina girl
put Nathan boy
put Kelly girl
put Walter boy
put Victoria girl
put Harold boy
136. put Lauren girl
put Kyle boy
put Martha girl
put Carl boy
put Judith girl
put Arthur boy
put Cheryl girl
put Gerald boy
put Megan girl
put Roger boy
put Andrea girl
put Keith boy
put Ann girl
put Jeremy boy
put Alice girl
put Terry boy
put Jean girl
put Lawrence boy
put Doris girl
put Sean boy
put Jacqueline girl
put Christian boy
put Kathryn girl
put Albert boy
put Hannah girl
put Joe boy
put Olivia girl
put Ethan boy
put Gloria girl
put Austin boy
put Marie girl
put Jesse boy
put Teresa girl
put Willie boy
put Sara girl
put Billy boy
137. put Janice girl
put Bryan boy
put Julia girl
put Bruce boy
put Grace girl
put Jordan boy
put Judy girl
put Ralph boy
put Theresa girl
put Roy boy
put Rose girl
put Noah boy
put Beverly girl
put Dylan boy
put Denise girl
put Eugene boy
put Marilyn girl
put Wayne boy
put Amber girl
put Alan boy
put Madison girl
put Juan boy
put Danielle girl
put Louis boy
put Brittany girl
put Russell boy
put Diana girl
put Gabriel boy
put Abigail girl
put Randy boy
put Jane girl
put Philip boy
put Natalie girl
put Harry boy
put Lori girl
put Vincent boy
138. put Tiffany girl
put Bobby boy
put Alexis girl
put Johnny boy
put Kayla girl
put Logan boy
__MACOSX/a1-code/data/._big.script~
a1-code/data/other.script~
put Lucas brash
put Mike DM
put Dustin corny
put Will lost
print
get Dustin
get El
get Lucas
get Jim
put El weird
put Steve hairy
put Nancy torn
put Barb ran-away?
print
hashcode Lucas
hashcode Barb
structure
expand
structure
save stranger.hm
clear
print
structure
put Jim cop
put Joyce worried
139. print
structure
get Dustin
get Joyce
load stranger.hm
print
structure
get Dustin
get Joyce
put Will found
put Nancy decided
put Mike girl-crazy
print
structure
next_prime 10
next_prime 25
expand
structure
put Jim cop
put Joyce worried
put Erica capitalist
put Barb gone
put Max gamer
save data/other.hm
quit
__MACOSX/a1-code/data/._other.script~
a1-code/data/names.org
| 1 | James | 4,815,847 | Mary | 3,455,228 |
| 2 | John | 4,636,242 | Patricia | 1,565,291 |
| 3 | Robert | 4,600,785 | Jennifer | 1,464,890 |
| 4 | Michael | 4,307,070 | Elizabeth | 1,449,478 |
| 5 | William | 3,689,740 | Linda | 1,447,946 |
140. | 6 | David | 3,553,094 | Barbara | 1,413,261 |
| 7 | Richard | 2,496,587 | Susan | 1,106,614 |
| 8 | Joseph | 2,398,378 | Jessica | 1,042,177 |
| 9 | Thomas | 2,179,445 | Margaret | 1,016,433 |
| 10 | Charles | 2,161,838 | Sarah | 997,223 |
| 11 | Christopher | 2,010,788 | Karen | 984,334 |
| 12 | Daniel | 1,866,234 | Nancy | 976,066 |
| 13 | Matthew | 1,571,799 | Betty | 964,130 |
| 14 | Anthony | 1,394,023 | Lisa | 964,099 |
| 15 | Donald | 1,375,006 | Dorothy | 938,467 |
| 16 | Mark | 1,342,682 | Sandra | 872,927 |
| 17 | Paul | 1,316,094 | Ashley | 840,595 |
| 18 | Steven | 1,276,216 | Kimberly | 833,129 |
| 19 | Andrew | 1,241,121 | Donna | 825,431 |
| 20 | Kenneth | 1,241,110 | Carol | 810,032 |
| 21 | George | 1,225,477 | Michelle | 807,515 |
| 22 | Joshua | 1,192,510 | Emily | 806,210 |
| 23 | Kevin | 1,162,743 | Amanda | 771,396 |
| 24 | Brian | 1,161,909 | Helen | 754,741 |
| 25 | Edward | 1,146,548 | Melissa | 750,021 |
| 26 | Ronald | 1,073,427 | Deborah | 739,055 |
| 27 | Timothy | 1,063,014 | Stephanie | 736,098 |
| 28 | Jason | 1,023,728 | Laura | 729,905 |
| 29 | Jeffrey | 972,144 | Rebecca | 729,158 |
| 30 | Ryan | 916,701 | Sharon | 720,788 |
| 31 | Gary | 898,893 | Cynthia | 705,176 |
| 32 | Jacob | 892,543 | Kathleen | 696,019 |
| 33 | Nicholas | 881,085 | Amy | 677,725 |
| 34 | Eric | 870,654 | Shirley | 675,723 |
| 35 | Stephen | 841,664 | Anna | 661,870 |
| 36 | Jonathan | 826,440 | Angela | 656,616 |
| 37 | Larry | 802,374 | Ruth | 633,144 |
| 38 | Justin | 769,098 | Brenda | 605,962 |
| 39 | Scott | 768,539 | Pamela | 592,689 |
| 40 | Frank | 753,168 | Nicole | 583,727 |
| 41 | Brandon | 749,649 | Katherine | 581,835 |