12.07.2015 Views

CPSC 221 - Project 2 Description - 2011W2 - Ugrad.cs.ubc.ca

CPSC 221 - Project 2 Description - 2011W2 - Ugrad.cs.ubc.ca

CPSC 221 - Project 2 Description - 2011W2 - Ugrad.cs.ubc.ca

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>CPSC</strong> <strong>221</strong> - <strong>Project</strong> 2 <strong>Description</strong> - <strong>2011W2</strong><strong>CPSC</strong> <strong>221</strong>, <strong>2011W2</strong>Contents1 Learning Objectives 22 Swiper no swiping! . . . and pre-Introduction 23 Introduction 23.1 The Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Dictionary Runner 34.1 Advice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Justifi<strong>ca</strong>tion 46 Milestone 1 (due Monday, March 5) 56.1 Deliverables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Milestone 2 (due Friday, March 9) 57.1 Deliverables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Final Submission (due Friday, March 16) 68.1 Deliverables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Bonus task/competition (recommended, but optional!) 7A Appendix: Marking Scheme 8B Appendix: Unix commands basic review 9Online PDF of this documentSee http://www.ugrad.<strong>cs</strong>.<strong>ubc</strong>.<strong>ca</strong>/~<strong>cs</strong><strong>221</strong>/<strong>2011W2</strong>/fun/description/project2.pdf.ChangelogAny changes to this document since it was released will be described here.1


<strong>Project</strong> 2<strong>CPSC</strong> <strong>221</strong> <strong>2011W2</strong>1 Learning Objectives• Learn, on your own, about a variety of data structures used to implement the dictionary(or set) ADT• Learn about tradeoffs between different implementations of ADTs (i.e. in a given situation,which works “best”, whatever that may mean)• Further familiarization with running times and other values measured using asymptoticnotation2 Swiper no swiping! . . . and pre-IntroductionSilly Context: Oh no! Swiper has stolen the dictionary implementations’ names! Can you helpDora find the names? Say “Swiper, no swiping!” and then help Dora figure out which is which.It doesn’t matter for the project, but if you don’t know who Dora and Swiper are, ask NaomiWolfman, or see: http://www.nickjr.co.uk/shows/dora/index.aspx.P.S. If you are familiar with Dora, get frustrated with the project, and need inspiration, try:http://kikigirl101.deviantart.com/art/Dora-Kills-Swiper-167986231.The background story and other useful help information <strong>ca</strong>n be found by running the dictionaryrunner (see below) with no arguments.3 IntroductionFor this project, you’ll once again be working in teams of 2. (Or alone, but we recommendgrabbing a partner.) As per the story, your goal is to, given 8 mystery implementations ofthe dictionary ADT, perform sequences of timed operations on them using a provided programknown as the dictionary runner (dict runner), and use the outputted timing data from theprogram to identify which of the mysXX corresponds to which dictionary implementation. Weguarantee there’ll be a unique bijection between the mystery dictionaries you’re given and thelist below!Note: you could refer to these data structures as either sets OR dictionaries be<strong>ca</strong>use we’reignoring the values stored inside the dictionaries and only using the keys, in effect treating themas sets. For the purposes of this project, we’ll simply refer to them as “dictionaries”.All of the dictionaries will store 64-bit unsigned integers. You will be able to insert, remove,and find entries in each dictionary by issuing commands to the dictionary runner via a file orstandard input, described later.And for the dictionaries you’ll be needing to identify. . . (drumroll please!)3.1 The Dictionaries• bstT: Binary search tree with tombstones• spt: Splay tree• avl: AVL tree• avlT: AVL tree with tombstonesPage 2


<strong>Project</strong> 2<strong>CPSC</strong> <strong>221</strong> <strong>2011W2</strong>• hlp: Hashtable with linear probing (resizing)• hqp: Hashtable with quadratic probing (resizing)• usl: Unsorted linked list• sl: Sorted vector (i.e., resizing array)They will each uniquely correspond to one of {mys01, mys02, mys03, . . . , mys08}, and this is thecorrespondence that you have to determine.Notice that some of these were not covered in class. In that <strong>ca</strong>se, you’ll have to lookthem up yourself: try consulting your favourite data structures textbook, Wikipedia, or asearch engine: http://lmgtfy.com/?q=splay+trees (or equally good, http://www.google.<strong>ca</strong>/search?q=Splay+tree).Just be sure to mention your sources in your assignment, following the A<strong>ca</strong>demic Conductpolicy (http://www.ugrad.<strong>cs</strong>.<strong>ubc</strong>.<strong>ca</strong>/~<strong>cs</strong><strong>221</strong>/current/syllabus.shtml#conduct).4 Dictionary RunnerThis program will live in the ~<strong>cs</strong><strong>221</strong>/project2/students/ directory and the filename will beyour user ID. You will not be provided the source.As this program only runs on the Linux machines, 1 you’ll need to SSH into one of theugrad machines: lulu, annacis, deas, lin01, lin02, .... Note that galiano is not aLinux machine. This program will perform operations on the dictionaries using the followingcommands, and must be placed one per line in the input:I F R The I, F, and R commands insert, find, and remove/delete the specified number, respectively.The number must be a POSITIVE integer. Inserting, finding, or removing 0 has unspecifiedbehaviour! Inserting a key already present will have no effect on the dictionary, nor willremoving a key not present in the dictionary.The mapping of the dictionary runner you’re provided is tied to your own ugrad ID, soeach person will have a different mapping (some may be the same, but unlikely, since there’s8! = 40320 different possible mappings!). Therefore, you must be clear which of your teammembers’ ugrad account is being used, and always handin using the same account.4.1 AdviceAs an example, once you’ve copied your executable to somewhere in your home directory andassuming you’ve compiled a program <strong>ca</strong>lled generator such as the following to generate somedictionary operation commands for you:#include #include // for atoi1 Techni<strong>ca</strong>lly, most Linux x86-64 machines will work, but no guarantees!Page 3


<strong>Project</strong> 2<strong>CPSC</strong> <strong>221</strong> <strong>2011W2</strong>using namespace std;int main(int argc, char* argv[]){if (argc != 2) // remember, argv[0] is the program name{cerr


<strong>Project</strong> 2<strong>CPSC</strong> <strong>221</strong> <strong>2011W2</strong>• Elimination (i.e. identifying all dictionaries but one, then concluding it must be theremaining one): This is a great way to lead yourself toward the right answer, but is notacceptable justifi<strong>ca</strong>tion alone.• A long table of runtime data: These are difficult to visually interpret unless plotted, and“these numbers obviously look like they fit a curve of the shape c 1 x + c 2 lg x + c 3 ”-typereasoning is unacceptable justifi<strong>ca</strong>tion.Reasoning deemed irrelevant or needlessly verbose will be subject to mark deduction as per themarking scheme (in Section A below). So, please proofread.One tool that will be useful is Matlab (or Gnuplot or other plotting/curve-fitting tools), whichis described at http://www.ugrad.<strong>cs</strong>.<strong>ubc</strong>.<strong>ca</strong>/~<strong>cs</strong><strong>221</strong>/random/fun/pp3-hint-plotting.html.If you’d prefer to use Gnuplot, you may find this tutorial (or another) useful: http://www.duke.edu/~hpgavin/gnuplot.html.If you’d like to use a L A TEX template for your writeup, here is one that may be useful:http://www.ugrad.<strong>cs</strong>.<strong>ubc</strong>.<strong>ca</strong>/~<strong>cs</strong><strong>221</strong>/<strong>2011W2</strong>/fun/description/project2-template.tex.6 Milestone 1 (due Monday, March 5)For this milestone, your goal is to identify which of the two mysXX dictionaries are the two lists(sorted vector, and unsorted linked list). Furthermore, you’ll need to determine which list is thesorted vector, and which is the unsorted linked list, and justify your answer.6.1 DeliverablesPlease include:• README.txt — plain text file with names, ugrad IDs, and whose dictionary runner wasused (e.g. “Dictionary runner used: a1b2”, but remember to also handin only from theaccount whose dictionary runner was used!).• justifi<strong>ca</strong>tion.pdf — justifi<strong>ca</strong>tion of your answers (a text file is acceptable for Milestone 1only, in which <strong>ca</strong>se you <strong>ca</strong>n include graphs as images instead of embedded in the PDF).Be sure to include key title information such as your names and ugrad IDs.• mapping.txt — a simple comma-separated text file containing a line for each mapping,precisely in the format this example: (not necessarily the same mapping, of course!)sl,mys08usl,mys04This is just so we <strong>ca</strong>n easily see what your choices were at a glance and automati<strong>ca</strong>llyassign the mapping correctness portion of the marks.7 Milestone 2 (due Friday, March 9)For this milestone, your goal is to identify which of the two mysXX dictionaries are hash tables.Furthermore, you’ll need to identify which uses linear probing, and which uses quadratic probing,and justify your answer.Page 5


<strong>Project</strong> 2<strong>CPSC</strong> <strong>221</strong> <strong>2011W2</strong>7.1 DeliverablesPlease include:• README.txt — plain text file with names, ugrad IDs, and whose dictionary runner wasused (e.g. “Dictionary runner used: a1b2”, but remember to also handin only from theaccount whose dictionary runner was used!).• justifi<strong>ca</strong>tion.pdf — justifi<strong>ca</strong>tion of your answers (this must be a PDF now!) including yourmapping for the lists from Milestone 1. Be sure to include key title information such asyour names and ugrad IDs.• mapping.txt — a simple comma-separated text file containing a line for each mapping,precisely in the format this example: (not the same mapping, of course)hlp,mys08hqp,mys04usl,mys03sl,mys06This is just so we <strong>ca</strong>n easily see what your choices were at a glance and automati<strong>ca</strong>llyassign the mapping correctness portion of the marks.8 Final Submission (due Friday, March 16)Now you must provide a complete mapping of mystery dictionaries to their implementations.8.1 DeliverablesAgain, please include the following:• README.txt — plain text file with names, ugrad IDs, and whose dictionary runner wasused (e.g. “Dictionary runner used: a1b2”, but remember to also handin only from theaccount whose dictionary runner was used!).• justifi<strong>ca</strong>tion.pdf — justifi<strong>ca</strong>tion of your answers. Be sure to include key title informationsuch as your names and ugrad IDs.• mapping.txt — a simple comma-separated text file containing a line for each mapping,precisely in the format this example: (not the same mapping, of course)bstT,mys02spt,mys07avl,mys05avlT,mys06hlp,mys08hqp,mys04usl,mys03sl,mys01This is just so we <strong>ca</strong>n easily see what your choices were at a glance and automati<strong>ca</strong>llyassign the mapping correctness portion of the marks.Page 6


<strong>Project</strong> 2<strong>CPSC</strong> <strong>221</strong> <strong>2011W2</strong>9 Bonus task/competition (recommended, but optional!)More information on this soon!Update: look here: http://www.ugrad.<strong>cs</strong>.<strong>ubc</strong>.<strong>ca</strong>/~<strong>cs</strong><strong>221</strong>/current/fun/description/bonus.Page 7


<strong>Project</strong> 2<strong>CPSC</strong> <strong>221</strong> <strong>2011W2</strong>AAppendix: Marking SchemeWhenever we judge your mapping of a mystery dictionary to its implementation, we will useroughly the following marking scheme:• EXCELLENT: The mapping is correct. The (concise) argument lays out the approach totesting (which styles of input and why) and the data itself (e.g., as a graph or easy-to-readtable), and analysis of the data clearly distinguishes the chosen implementation from allother posssibilities.• GOOD: The mapping is correct, and the argument is sensible but not complete.example, may be missing one or more of:For– what styles of input were used for testing,– why those styles of input are useful for distinguishing this particular implementation,– a summary of the data used in the argument (e.g. a graph or an easy-to-read table,not hundreds or thousands of numbers),– what about the data (i.e. graph/table) supports the mapping to a particular dictionaryimplementation when compared to others.We may also use this <strong>ca</strong>tegory for unnecessarily verbose answers that are otherwise excellent.• GOOD [WRONG MAPPING]: The mapping is incorrect, but the argument for themapping is solid (see above), presumably missing some factor that if considered wouldhave yielded the correct mapping. (Worth roughly the same as POOR below.)• POOR: The mapping is correct but the explanation makes little or no <strong>ca</strong>se for how theparticular implementation was reliably distinguished from all other implementations.• POOR [WRONG MAPPING]: The mapping is incorrect and the explanation makeslittle or no <strong>ca</strong>se for how the particular implementation was reliably distinguished from allother implementations. (Worth roughly the same as NONE below.)• NONE: No submission or submission is unreadable or irrelevant.Page 8


<strong>Project</strong> 2<strong>CPSC</strong> <strong>221</strong> <strong>2011W2</strong>B Appendix: Unix commands basic reviewCommand <strong>Description</strong>ls List the contents of the current directory.ls somedirectory List the contents of somedirectory.cd Change the current directory to your home directory (which you <strong>ca</strong>n also refer toas $HOME or ~).cd somedirectory Change the current directory to somedirectory.mkdir somedir Makes a new subdirectory to the current directory <strong>ca</strong>lled somedir, or if an absolutepath is specified, a new subdirectory in that directory.less somefile View the contents of somefile screenful by screenful. Press q to quit.g++ -g -o asdf asdf.cpp Compiles a C++ source file asdf.cpp to an executable <strong>ca</strong>lled asdf that you <strong>ca</strong>n executeusing ./asdf. The -g flag instructs g++ to compile with debugging informationso you <strong>ca</strong>n use gdb to debug it if you want (you <strong>ca</strong>n omit this if you don’t wantit), and the -o filename flag instructs g++ to compile the executable to the namefilename.program1 | program2 Pipe the standard output of program1 into the standard input of program2.For more, please look online or look over some of the lab material that goes over these programs.The CS department has information on how to remotely connect to the ugrad Linux servers via SSH (including instructions oninstalling and using XManager, which is useful if you’re running Windows):• https://www.<strong>cs</strong>.<strong>ubc</strong>.<strong>ca</strong>/support/connecting-<strong>cs</strong>-undergrads• https://www.<strong>cs</strong>.<strong>ubc</strong>.<strong>ca</strong>/support/faq-remote-computing-undergradPage 9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!