Skip to content

Commit 47f3c76

Browse files
committed
report updates
1 parent 20b722a commit 47f3c76

File tree

5 files changed

+198
-39
lines changed

5 files changed

+198
-39
lines changed

report/document.aux

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
\@writefile{toc}{\contentsline {section}{\numberline {II}Solutions}{1}\protected@file@percent }
44
\@writefile{toc}{\contentsline {subsection}{\numberline {\unhbox \voidb@x \hbox {II-A}}Brute-Force Approach}{1}\protected@file@percent }
55
\@writefile{loa}{\contentsline {algorithm}{\numberline {1}{\ignorespaces Brute-Force}}{1}\protected@file@percent }
6+
\@writefile{toc}{\contentsline {subsection}{\numberline {\unhbox \voidb@x \hbox {II-B}}Divide \& Conquer Approach}{1}\protected@file@percent }
7+
\@writefile{loa}{\contentsline {algorithm}{\numberline {2}{\ignorespaces Divide \& Conquer}}{2}\protected@file@percent }

report/document.log

Lines changed: 124 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex 2019.10.29) 17 NOV 2019 14:12
1+
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex 2019.10.29) 17 NOV 2019 15:31
22
entering extended mode
33
restricted \write18 enabled.
44
%&-line parsing enabled.
@@ -657,37 +657,138 @@ Underfull \hbox (badness 10000) in paragraph at lines 33--36
657657

658658
[]
659659

660-
LaTeX Font Info: Try loading font information for OMS+ptm on input line 52.
661-
(/usr/local/texlive/2019/texmf-dist/tex/latex/psnfss/omsptm.fd
662-
File: omsptm.fd
663-
)
664-
LaTeX Font Info: Font shape `OMS/ptm/m/n' in size <10> not available
665-
(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 52.
666-
[1{/usr/local/texlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}
667660

661+
Underfull \hbox (badness 10000) in paragraph at lines 53--54
662+
663+
[]
664+
665+
Missing character: There is no [ in font nullfont!
666+
Missing character: There is no b in font nullfont!
667+
Missing character: There is no o in font nullfont!
668+
Missing character: There is no x in font nullfont!
669+
Missing character: There is no / in font nullfont!
670+
Missing character: There is no . in font nullfont!
671+
Missing character: There is no s in font nullfont!
672+
Missing character: There is no t in font nullfont!
673+
Missing character: There is no y in font nullfont!
674+
Missing character: There is no l in font nullfont!
675+
Missing character: There is no e in font nullfont!
676+
Missing character: There is no = in font nullfont!
677+
Missing character: There is no r in font nullfont!
678+
Missing character: There is no e in font nullfont!
679+
Missing character: There is no c in font nullfont!
680+
Missing character: There is no t in font nullfont!
681+
Missing character: There is no a in font nullfont!
682+
Missing character: There is no n in font nullfont!
683+
Missing character: There is no g in font nullfont!
684+
Missing character: There is no l in font nullfont!
685+
Missing character: There is no e in font nullfont!
686+
Missing character: There is no , in font nullfont!
687+
Missing character: There is no d in font nullfont!
688+
Missing character: There is no r in font nullfont!
689+
Missing character: There is no a in font nullfont!
690+
Missing character: There is no w in font nullfont!
691+
Missing character: There is no = in font nullfont!
692+
Missing character: There is no b in font nullfont!
693+
Missing character: There is no l in font nullfont!
694+
Missing character: There is no a in font nullfont!
695+
Missing character: There is no c in font nullfont!
696+
Missing character: There is no k in font nullfont!
697+
Missing character: There is no , in font nullfont!
698+
Missing character: There is no u in font nullfont!
699+
Missing character: There is no l in font nullfont!
700+
Missing character: There is no t in font nullfont!
701+
Missing character: There is no r in font nullfont!
702+
Missing character: There is no a in font nullfont!
703+
Missing character: There is no t in font nullfont!
704+
Missing character: There is no h in font nullfont!
705+
Missing character: There is no i in font nullfont!
706+
Missing character: There is no c in font nullfont!
707+
Missing character: There is no k in font nullfont!
708+
Missing character: There is no , in font nullfont!
709+
Missing character: There is no m in font nullfont!
710+
Missing character: There is no i in font nullfont!
711+
Missing character: There is no n in font nullfont!
712+
Missing character: There is no i in font nullfont!
713+
Missing character: There is no m in font nullfont!
714+
Missing character: There is no u in font nullfont!
715+
Missing character: There is no m in font nullfont!
716+
Missing character: There is no s in font nullfont!
717+
Missing character: There is no i in font nullfont!
718+
Missing character: There is no z in font nullfont!
719+
Missing character: There is no e in font nullfont!
720+
Missing character: There is no = in font nullfont!
721+
Missing character: There is no 0 in font nullfont!
722+
Missing character: There is no . in font nullfont!
723+
Missing character: There is no 5 in font nullfont!
724+
Missing character: There is no c in font nullfont!
725+
Missing character: There is no m in font nullfont!
726+
Missing character: There is no , in font nullfont!
727+
Missing character: There is no ] in font nullfont!
728+
729+
Underfull \hbox (badness 10000) in paragraph at lines 89--116
730+
731+
[]
732+
733+
734+
Underfull \hbox (badness 10000) in paragraph at lines 89--116
735+
736+
[]
737+
738+
739+
Underfull \hbox (badness 10000) in paragraph at lines 89--116
740+
741+
[]
742+
743+
744+
Underfull \hbox (badness 10000) in paragraph at lines 89--116
745+
746+
[]
747+
748+
749+
Underfull \hbox (badness 10000) in paragraph at lines 89--116
750+
751+
[]
752+
753+
754+
Underfull \hbox (badness 10000) in paragraph at lines 89--116
755+
756+
[]
757+
758+
759+
Underfull \hbox (badness 10000) in paragraph at lines 89--116
760+
761+
[]
762+
763+
[1{/usr/local/texlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}
764+
765+
766+
]
767+
[2
668768

669769
] (./document.aux) )
670770
Here is how much of TeX's memory you used:
671-
12710 strings out of 492616
672-
259161 string characters out of 6129480
673-
305629 words of memory out of 5000000
674-
16405 multiletter control sequences out of 15000+600000
771+
12712 strings out of 492616
772+
259247 string characters out of 6129480
773+
314629 words of memory out of 5000000
774+
16410 multiletter control sequences out of 15000+600000
675775
35192 words of font info for 64 fonts, out of 8000000 for 9000
676776
1141 hyphenation exceptions out of 8191
677-
55i,6n,60p,855b,659s stack positions out of 5000i,500n,10000p,200000b,80000s
777+
55i,7n,60p,855b,674s stack positions out of 5000i,500n,10000p,200000b,80000s
678778
{/usr/local/texlive/2019/texmf-dist/fonts/enc/dvips/base/8r
679779
.enc}</usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.
680-
pfb></usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pf
681-
b></usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb><
682-
/usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></
683-
usr/local/texlive/2019/texmf-dist/fonts/type1/urw/times/utmb8a.pfb></usr/local/
684-
texlive/2019/texmf-dist/fonts/type1/urw/times/utmbi8a.pfb></usr/local/texlive/2
685-
019/texmf-dist/fonts/type1/urw/times/utmr8a.pfb></usr/local/texlive/2019/texmf-
686-
dist/fonts/type1/urw/times/utmri8a.pfb>
687-
Output written on document.pdf (1 page, 82214 bytes).
780+
pfb></usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pf
781+
b></usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
782+
</usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></u
783+
sr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></us
784+
r/local/texlive/2019/texmf-dist/fonts/type1/urw/times/utmb8a.pfb></usr/local/te
785+
xlive/2019/texmf-dist/fonts/type1/urw/times/utmbi8a.pfb></usr/local/texlive/201
786+
9/texmf-dist/fonts/type1/urw/times/utmr8a.pfb></usr/local/texlive/2019/texmf-di
787+
st/fonts/type1/urw/times/utmri8a.pfb>
788+
Output written on document.pdf (2 pages, 95848 bytes).
688789
PDF statistics:
689-
44 PDF objects out of 1000 (max. 8388607)
690-
32 compressed objects within 1 object stream
790+
51 PDF objects out of 1000 (max. 8388607)
791+
37 compressed objects within 1 object stream
691792
0 named destinations out of 1000 (max. 500000)
692793
13 words of extra memory for PDF output out of 10000 (max. 10000000)
693794

report/document.pdf

13.3 KB
Binary file not shown.

report/document.synctex.gz

4.85 KB
Binary file not shown.

report/document.tex

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,82 @@ \subsection{Brute-Force Approach}
3737
\begin{algorithm}
3838
\caption{Brute-Force}
3939
\begin{algorithmic}
40-
\STATE $y \leftarrow 1$
41-
\IF{$n < 0$}
42-
\STATE $X \leftarrow 1 / x$
43-
\STATE $N \leftarrow -n$
44-
\ELSE
45-
\STATE $X \leftarrow x$
46-
\STATE $N \leftarrow n$
40+
\STATE $n \leftarrow len(array) $
41+
\STATE $max_sum \leftarrow 0$
42+
\FOR {$ i \leftarrow 1$ to $ n $}
43+
\FOR{$j \leftarrow 1$ to $n$}
44+
\STATE $sum += array[j]$
45+
\IF{$sum > max\_sum$}
46+
\STATE $max\_sum \leftarrow sum$
47+
\ENDIF
48+
\ENDFOR
49+
\ENDFOR
50+
\end{algorithmic}
51+
\end{algorithm}
52+
\subsection{Divide \& Conquer Approach}
53+
Another solution is to divide the array into half recursively and computing the max subarray sum for each half and the sub array for crossing both halfs. After calculating the summation for these 3 cases, we choose the largest one, thus we determine the maximum sub array.\\
54+
55+
\begin{tikzpicture}[transform canvas={scale=.5}, trim left=-2.5cm]
56+
[%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57+
box/.style={rectangle,draw=black, ultra thick, minimum size=0.5cm},
58+
]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59+
60+
\foreach \x/\y in {0/9, 1/5,2/13,3/19,4/12,5/8,6/7,7/4}
61+
\node[box] at (\x,0){\y};
62+
63+
%\draw[->,very thick] (0,1.2) -- node[above,yshift=2mm]{start} (0,.7);
64+
%\draw[->,very thick] (1,1.2) -- node[above,yshift=2mm]{end} (1,.7);
65+
\draw[->,very thick] (3.45,-.7) -- (1,-2);
66+
\draw[->,very thick] (3.55,-.7) -- (6,-2);
67+
68+
\foreach \x/\y in {-1/9, 0/5,1/13,2/19}
69+
\node[box] at (\x,-3){\y};
70+
71+
\foreach \x/\y in {5/12, 6/8,7/7,8/4}
72+
\node[box] at (\x,-3){\y};
73+
74+
\draw[->,very thick] (0.45,-3.6) -- (-0.7,-4);
75+
\draw[->,very thick] (0.55,-3.6) -- (1.7,-4);
76+
77+
\draw[->,very thick] (6.45,-3.6) -- (5.35,-4);
78+
\draw[->,very thick] (6.55,-3.6) -- (7.65,-4);
79+
80+
\foreach \x/\y in {8/7,9/4}
81+
\node[box] at (\x,-5){\y};
82+
\foreach \x/\y in {4.5/12, 5.5/8}
83+
\node[box] at (\x,-5){\y};
84+
85+
\foreach \x/\y in {-2/9,-1/5}
86+
\node[box] at (\x,-5){\y};
87+
\foreach \x/\y in {1.5/13,2.5/19}
88+
\node[box] at (\x,-5){\y};
89+
\end{tikzpicture}
90+
\\ \\ \\ \\ \\ \\ \\ \\
91+
\begin{algorithm}
92+
\caption{Divide \& Conquer}
93+
\begin{algorithmic}
94+
\STATE \textbf{function} max\_crossing\_sub\_array$(array, l, m, h)$
95+
\STATE$left\_max\_sum \leftarrow -100000$
96+
\STATE$sum\_l \leftarrow 0$
97+
\FOR{$ i \leftarrow m$ \textbf{downto} $l - 1$}
98+
\STATE$sum\_l \leftarrow sum\_l + array[i]$
99+
\IF{$sum\_l > left\_max\_sum$}
100+
\STATE $left\_max\_sum \leftarrow sum\_l$
47101
\ENDIF
48-
\WHILE{$N \neq 0$}
49-
\IF{$N$ is even}
50-
\STATE $X \leftarrow X \times X$
51-
\STATE $N \leftarrow N / 2$
52-
\ELSE[$N$ is odd]
53-
\STATE $y \leftarrow y \times X$
54-
\STATE $N \leftarrow N - 1$
102+
\ENDFOR
103+
104+
\STATE $sum\_r \leftarrow 0$
105+
\STATE $right\_max\_sum \leftarrow -100000$
106+
\FOR{$ j \leftarrow m + 1$ \TO $h + 1$}
107+
\STATE$sum\_r \leftarrow sum\_r + array[j]$
108+
\IF{$sum\_r > right\_max\_sum$}
109+
\STATE $right\_max\_sum \leftarrow sum\_r$
55110
\ENDIF
56-
\ENDWHILE
111+
\ENDFOR
112+
\RETURN$left\_max\_sum + right\_max\_sum )$
113+
57114
\end{algorithmic}
58115
\end{algorithm}
59116

60117

61-
62118
\end{document}

0 commit comments

Comments
 (0)