Преглед на файлове

small errors in naming, unneeded parameter

tarfeef101 преди 6 години
родител
ревизия
837eb85862
променени са 2 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. BIN
      341-a3-q4.pdf
  2. 3 3
      341-a3-q4.tex

BIN
341-a3-q4.pdf


+ 3 - 3
341-a3-q4.tex

@@ -19,7 +19,7 @@
 
 \begin{document}
 \maketitle
-\section{Bookshelf Problem Part 1}
+\section{Scriptio Continua Part 1}
 
 \subsection{Description/Correctness}
 First, create an array of length n. Each element is a flag that indicates if there is a solution for a substring of length i+1 (since array[0] is length 1). This should be all false at the start.
@@ -32,7 +32,7 @@ After this loop completes, we have a prefix array that is true wherever there ex
 
 \subsection{Pseudocode}
 \begin{verbatim}
-bool wordBreak(set d, String s)
+bool wordBreak(String s)
 {
   int len = s.length();
   if (!len) return true;
@@ -71,7 +71,7 @@ Now, we have a loop that loops n times. Each time, we:
   Or, we loop from 0 up to i (as j), and check an array index and use isWord again, and potentially set an array value. This is up to 3 constant time operations, done up to i times (which is up to n since i loops up to n). This inner loop is $\Theta$(n).
 This loop does O(n) work (since sometimes it is $\Theta$(1), other times $\Theta$(n)), and does that n times. This means it is O($n^2$).
 
-\section{Bookshelf Problem Part 2}
+\section{Scriptio Continua Problem Part 2}
 \subsection{Modification to output the solution in words}
 In order to print the solution out, we create an array of strings of length n. Each index correpsonds to the same index in the array of booleans from part a. Whenever a boolean is flagged as true, the substring used for that value is stored in the array of strings at the same index. Then, once our algorithm produces "true", we print out the array at index (n - 1), and each succesive index where that index is equal to the previous minus the length of the printed string. Since the isWord function uses a substring and takes constant time, we can assume we can also use a substring of the input with the same efficiency, so the building of this string array should take constant time. As for printing it out, we loop up to n times (if the substrings are all length n), so this would be $\Theta$(n) at the end, and therefore would not affect the runtime.