I am adding one image using \includegraphic command, but it is coming in the top of page not in the right position.
See my code give below:
\documentclass{amsart}
\usepackage{a4wide}
\newtheorem{mydef}{Definition}
\usepackage[T1]{fontenc}
\newtheorem{thm}{Theorem}
\renewcommand{\baselinestretch}{1.5}
\usepackage{tabularx}
\usepackage{algorithm,algpseudocode}
\usepackage{tabularx}
\usepackage{amsthm}
\newtheorem{definition}{Definition}[section]
\usepackage{graphicx}
\usepackage{tabularx,lipsum,environ,amsmath,amssymb}
\usepackage{tabularx}
\makeatletter
\newcommand{\problemtitle}[1]{\gdef\@problemtitle{#1}}% Store problem title
\newcommand{\probleminput}[1]{\gdef\@probleminput{#1}}% Store problem input
\newcommand{\problemquestion}[1]{\gdef\@problemquestion{#1}}% Store problem question
\NewEnviron{problem}{
\problemtitle{}\probleminput{}\problemquestion{}% Default input is empty
\BODY% Parse input
\par\addvspace{.5\baselineskip}
\noindent
\begin{tabularx}{\textwidth}{@{\hspace{\parindent}} l X c}
\multicolumn{2}{@{\hspace{\parindent}}l}{\@problemtitle} \\% Title
\textbf{Input:} & \@probleminput \\% Input
\textbf{Question:} & \@problemquestion% Question
\end{tabularx}
\par\addvspace{.5\baselineskip}
}
\newcommand{\avsum}{\mathop{\mathpalette\avsuminner\relax}\displaylimits}
\makeatletter
\newcommand\avsuminner[2]{%
{\sbox0{$\m@th#1\sum$}%
\vphantom{\usebox0}%
\ooalign{%
\hidewidth
\smash{\vrule height\dimexpr\ht0+1pt\relax depth\dimexpr\dp0+1pt\relax}%
\hidewidth\cr
$\m@th#1\sum$\cr
}%
}%
}
\makeatother
\title{Computing Prime Set in \mathcal{O}(n) Running Time}
\author{Sh \\~\\ IIT[![enter image description here][1]][1] Ga}
\begin{document}
\section{Computing Primes beween 2 and $k-1$}
\begin{problem}
\problemtitle{$$\textsc{Prime Set}}
\probleminput{ An array $N$ is given such that $N[i] = i,2\le i \le k-1$ .}
\problemquestion{ Compute set $Q_{k-1}$ which contains primes between 2 and $k-1$}
\end{problem}
We want to compute the primes beween 2 and $k-1$. A simple algorithm is to start with 2 and mark the elements that are multiple of two and in the second iteration mark the multiples of 3 and so on. Let $N$ be an array containing numbers from 2 to $k-1$ such that $N[i] = i$.
\begin{itemize}
\item For $i =2$ to $k$
\begin{itemize}
\item Mark the multiples of $i$ in array $N$.
\end{itemize}
\item End For
\end{itemize}
It is easy to see that above algorithm takes $\mathcal{O}(k \log k)$ .
We want to improve the running time of the above algorithm from time $O(k \log \log k)$ to $O(k)$ time. The problem with the above algorithm is that there will be many elements in $N$ which get marked multiple times like 6, 12 etc. To avoid that an element get marked multiple times, we will use a doubly linked list with pointers to array $N$. See the image below for more detail.
\begin{figure}
\includegraphics[scale=0.1]{Downloads/img.jpg}
\end{figure}
From the above diagram it is clear that we are maintaing a one pointer from node $i$ of the list $L$ to index $i$ of array $N$ and one pointer from index $i$ of $N$ to $i$th node of list $L$. Now algorithm to compute the prime set$Q_{k-1}$ is given below:
\begin{itemize}
\item Pick the smallest unmarked element $i \ge 2$ in $N$ and add $i$ to $Q_{k-1}$.
\item Starting from the first node, walk up the list $L$ in increasing order until we find the smallest number $r$ in it such that $r.i \ge k-1$.
\item Walk down the list $L$ ( crucially, in decreasing order ) from the node $r$, and for each $l$ in $L$, seen, mark the element $N[i.l]$ and delete the node containing $i.l$ from $L$ ( this node in $L$ is accessed through the pointer from the $(i.l)$th location in $N$ ).
\item If $N$ has any unmarked element $\ge 2$, go back to first step
\end{itemize}
In the first round all the multiple of 2 will get marked. It is easy to verify that each element in the array will get marked just once. The overall running time of above algorithm is $O(k)$ ( verify this ).
\end{document}
Question : How to modify so that author name and image comes in right position (where I have added image)?
See my complied pdf :
[htbp]
as an option to the figure env, the h, making "here if possible" s not a part of the default value), alway have captions on them and refer to the number given by the caption. Otherwise don't use a float (here figure),, you could replace it with the center env, but if the image is large, and is close to a page break, it will be moved to the next page leaving a big hole behind. – daleif Feb 11 '18 at 14:28\begin{figure}[!h]
, or better, don't let it float: use\begin{center}\includegraphics{...}\end{center}
. Unrelated: don't use a4wide anymore. You can replace it with packagegeometry
and set\geometry{a4paper}
. – Bernard Feb 11 '18 at 14:30