Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latex formatting and improved html tag open-close pairing #426

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions src/lab/exp3/Quizzes.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
<title>Welcome to Virtual Labs - A MHRD Govt of india Initiative</title>

<link rel="shortcut icon" href="../images/favicon.ico">

<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

<link href="../css/bootstrap.min.css" rel="stylesheet">

Expand All @@ -26,6 +31,7 @@
<script type="text/javascript" src = 'tabs.js'></script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-67020197-1', 'auto');ga('send', 'pageview');</script>
</head>

<body id="page-top" class="index">
<div id="top">
<header>
Expand Down Expand Up @@ -116,60 +122,60 @@ <h2 class="text-h2-lightblue" style=" margin-bottom: 20px; margin-top: 10px; "><
<h1 class="text-h2-lightblue">Sorting Algorithms</h1><div class="content" id="experiment-article-section-6-content">
<h3>Easy Questions</h3>
<br>
<p>Answer the following questions with respect to sorting algorithms on arrays.
<p>Answer the following questions with respect to sorting algorithms on arrays. </p>

<ul>
<li> <p> Are there sorting algorithms that take the same asymptotic runtime irrespective of the input?
<li> <p> Most of the algorithms we studied so far made no assumptions on the maximum input values in the input. When some bounds on the input values are known, it is possible to design sorting algorithms that benefit from this knowledge. A simple example is the following: Let A be a set of n numbers whose values are between 1 to O(n). Now, to sort A, declare an array B of size max A[i]. Mark B[i] as 1 iff A[j] = i. Now, print i if B[i] =1 in increasing order of i. Can you modify this scheme when the maximum number in A in more than O(n), say in O(n^2), while still using only |A| space?
<li> An inversion is a pair of indices $i$ and
$j$ so that $A[i]$ more than A[j]$ but $i$ is less than j$, i.e., elements are not in the
<li> <p> Are there sorting algorithms that take the same asymptotic runtime irrespective of the input? </p></li>
<li> <p> Most of the algorithms we studied so far made no assumptions on the maximum input values in the input. When some bounds on the input values are known, it is possible to design sorting algorithms that benefit from this knowledge. A simple example is the following: Let A be a set of n numbers whose values are between 1 to O(n). Now, to sort A, declare an array B of size max A[i]. Mark B[i] as 1 iff A[j] = i. Now, print i if B[i] =1 in increasing order of i. Can you modify this scheme when the maximum number in A in more than O(n), say in O($n^2$), while still using only |A| space?
</p></li>
<li><p> An inversion is a pair of indices $i$ and $j$ so that $A[i]$ more than $A[j]$ but $i$ is less than $j$, i.e., elements are not in the
natural(sorted) order. Design an algorithm based on sorting algorithms to count the number of inversions in a given array A of n numbers.
</li></p></li></p></li></ul>
<ul>
</p></li>
</ul>

<h3>Difficult Questions</h3>
<p> Notice that for merge sort to work, one does not need to know the
entire data at once. Consider settings where the entire data may not
it into the memory of a computer system. In that case, one can bring
in as much data as it is possible to work with, sort in piece and then
write back the sorted piece, and bring fresh unsorted data in to the
memory.

</p>
<p> Once all data is sorted in pieces, these pieces can be then merged in a
similar fashion.

</p>
<p> This process is called as "external sorting'' as we imagine that the
data is available externally to the computer. Merge sort is one such
sorting algorithm that extends naturally to an external setting.

</p>
<p> Problem: Develop the idea of external sorting using merge sort.
Describe the nature of data movements that are to be used in your
scheme.

</p>
<p> Problem: Why would insertion sort not work in an external setting?

</p>
<p> Since it is clear that merge sort can work with only partial data, it
may be possible to think of a parallel version of merge sort. One can
view a parallel algorithm as follows. An algorithm is a sequence of
tasks $T1_, T_2, \cdots$. These tasks may have inter-dependecies, so
tasks $T_1, T_2, \cdots$. These tasks may have inter-dependecies, so
that task $T_i$ should be completed before task $T_j$ for some $i,j$.
However, it is often the case that there are several algorithms where
many tasks are independent of each other. (In some cases, the algorithm
or the computation has to be expressed in that indepedent-task
fashion). In such a setting, one can imagine that tasks that are
indepedent of each other can be done simultaneously, or in parallel.

</p>
<p>Consider such parallel execution and the problem of sorting a given set
of numbers. When using merge sort, we divide the input into two parts.
These two tasks -- of sorting each part -- are independent of each
other and hence can be done in parallel. So let us investigate this
possibility further. We have to also merge sorted sequences. The way we
have described merge sort, when merging two sequences of length $\ell$
each, we have $2\ell$ tasks. These $2\ell$ tasks find the position of
each element in the two merged seuqences in the combined sequence of
each element in the two merged sequences in the combined sequence of
$2\ell$ elements. These $2\ell$ tasks are also completely dependent in
the way they are written. However, a rewrite is possible.

</p>
<p>Let us call the two sorted sequences as $A$ and $B$. Think of searching
for each element of $A$ in $B$ and vice-versa. Since the sequences $A$
and $B$ are sorted, one can use binary search. Still there are $2\ell$
Expand All @@ -178,15 +184,15 @@ <h3>Difficult Questions</h3>
index $i'$ where $i'= i + Rank(A[i], B)$. In the former expression,
$Rank(A[i], B)$ refers to the rank of element $A[i]$ in the array $B$
obtained using binary search.

</p>
<p>There are several enhancements to the above idea of a simple parallel
merge sort. An interested reader can find more details in the book ''An
Introduction to Parallel Algorithms'', by J. JaJa.

</p>


</p></p></p></p></p></p></p></p></p></ul>
</p></li></div> </div>
</ul>
</div> </div>
</div>
</div>
<!-- =================================================================================================================================== -->
Expand Down