As the title implies, I'm trying to compile a tex file but it's hanging after displaying the message

"This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6500 64-bit)
entering extended mode
("D:/math assignments/TeX/Compass3.tex"
LaTeX2e <2017-04-15>
Babel <3.15> and hyphenation patterns for 75 language(s) loaded.

I'm using TeXworks pdfLaTex+MakeIndex+BibTex

My code is below


\title{COMP 2823: Asignment 5}
\author{Student ID: Student Number}

\rhead{SID: Student Number}




Scan the array once to determine the element with the least priority. This                 
element is necessarily the root of our tree if we are to satisfy the heap 
order requirement. Sort the remaining elements into two arrays, those with 
keys less than that of the root and those with keys greater. Repeat the 
procedure recursively on the two arrays to create the left and right 
subtrees of the root respectively. These two scans require $n + (n - 1)\leq 
2n$ comparisons (one scan over all of the elements to determine the element 
with the least priority and one scan over all the remaining elements to sort 
the elements into the two sub arrays). Note that at each level of the tree, 
the total number of pairs that need to be scanned is no more than $n-k+1$, 
where $k$ is the depth of the recursion because an element is removed from 
the pool of pairs yet to be inserted into the tree each time the function is 
called. $\therefore$
f(n) &\leq \sum_{k=0}^{n}2k \\
&\leq 2\sum_{k=0}^{n}k \\
&\leq \frac{2n(n+1)}{2} \\
&\leq n(n+1) \\
\therefore \text{ } f(n) &\in O(n^{2})
\subsection{Pseudo Code}
Tree $\gets$ BinarySearchHeap(Null)
\State Node MinP, MinK $\gets$ Array[0],  Array[0].Priority, Array[0].Key
\For{Pair in Array}
    \If{Pair[Priority] $<$ MinP}
        \State Node $\gets$ Pair
        \State MinP $\gets$ Pair.Priority
        \State MinK $\gets$ Pair.Key
\State Tree.Root $\gets$ Node
\State Array.Remove(Node)
\State Lesser, Greater $\gets$ [], []
\For{Pair in Array}
    \If{Pair.Key < MinK}
        \State Lesser.Append(Pair)
        \State Greater.Append(Pair)
\State Tree.Root.Left $\gets$ BSH(Lesser)
\State Tree.Root.Left $\gets$ BSH(Greater)
\State \Return Tree

The algorithm will consist of two stages, an initial Binary Search Tree 
isertion and then a modified upheap procedure to attain the heap property 
while preserving the Binary Search Tree property. \\
Assume that at some point on our algorthm the tree is a Binary Search Tree, 
the subtree rooted at the new node is a valid Binary Search Heap, and that 
the entire tree barring the new node preserves the Heap Property, (note that 
if the enitrety of the tree including the new node satisfies the Binary 
Search Heap property then our algorithm is complete). By assumption, the new 
node has priority lesser than its parent. Suppose it is the right child of 
it's parent, We make the new node the child of it's parent's parent (or the 
root if its parent was the root). Note that the new node's parent had lesser 
priority than any of the new node's children, and is lesser than the new 
node. We make the new node's parent the left child of the new node, note 
that since the new node was the right child of its parent originally, the 
parent has a vacancy for a right child. Since all the children of the new 
node were greater than its parent, the subtree rooted at its (the new 
node's) is composed of elements greater than the old parent and has greater 
priority, and therefore appending it as the right child of the old parent 
will preserve the Binary Search Heap properties.


It was working fine yesterday but today it won't compile, the only thing I believe I've added/changed since then is the "Insertion" section.

  • 1
    I can compile that code. Off topic: you should not have a section without title. – JouleV Apr 2 at 8:44
  • 4
    @JouleV I don't think there is any issues with having a section with no title. – daleif Apr 2 at 8:57
  • @daleif Of course there are no issues. That is why I said "should" instead of "must". – JouleV Apr 2 at 8:58
  • I tried creating a new file with the same code and encountered the same problem. Should I reinstall TeXworks? – Marvin GaTeX Apr 2 at 9:21
  • TeXworks just calls latex, I would try compiling it directly on the command line, to rule out texworks issues (of which I do not think there are any) – daleif Apr 2 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.