# publicrf/cs211-project1

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

file 77 lines (55 sloc) 2.395 kb
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 \documentclass[10pt]{article}\usepackage{color}\usepackage{verbatim}\usepackage[T1]{fontenc}\setlength{\headsep}{.33in}\setlength{\topsep}{0in}\setlength{\topmargin}{-1in}\setlength{\topskip}{0.4in} % between header and text\setlength{\textheight}{11in} % height of main text\setlength{\textwidth}{7.05in} % width of text\setlength{\oddsidemargin}{-0.30in} % odd page left margin\setlength{\evensidemargin}{-0.30in} % even page left margin\setlength{\parindent}{0in} % remove paragraph indenting\linespread{1.13}\newcommand{\head}[1]{   \begin{tabular*}{7.1in}{@{}l@{\extracolsep{\fill}}r}      Russell Frank & \today \\   \end{tabular*}   \begin{center} \LARGE #1 \normalsize \end{center}   \vskip 0.1in}\begin{document}\head{CS112 Assignment \#1}\section{SYNOPSIS}wordstat -l | -w | -p | -h INPUT\_FILE\section{USAGE}\begin{tabular}{ll}   -l & print the number of lines in INPUT\_FILE \\   -w & print the number of words in INPUT\_FILE \\   -p & print a report of palindromes in the INPUT\_FILE including frequency        and whether or not they appear in dict.txt\\   -h & print usage \\\end{tabular}\section{DESIGN}I used C standard library functions for all data structure requirements.I needed something with fast lookup and insert for the dictionary and thelist of words; so, I used bsearch for lookups and qsort for sorting. \\Unfortunately, since I wasn't allowed to use some standard C library functions,I had to rewrite bsearch and qsort. These are in mystdlib.c.The design is a little inefficient because I don't use the results of thefailed bsearch()es for inserting values into the array. So, I append avalue on the end of the array and qsort(). This could be considered a flawin libc's bsearch function.\section{RUNNING TIME}The searches use a binary search and the inserts use qsort(). My qsort() isimplemented as a quicksort, which on average has sorting time $O(n \log n)$.In the average case, binary searches are $O(\log n)$. So, the running time ofmy algorithm in the average case is $O(n \log n + \log n) = O(n \log n)$.\section{SPACE COMPLEXITY}My algorithm uses no extra memory past what is needed to store the wordsthemselves. So, $O(k + n)$, where $k$ is the number of files in thedictionary and $n$ is the number of words in the input file.\section{CHALLENGES}None.\end{document}
Something went wrong with that request. Please try again.