sIEve中文使用文档

sIEve项目是为了是为了发现和解决由于Internet Explorer中垃圾回收器(garbage collector)的容量限制所引起的内存泄露问题。例如执行AJAX这样的应用程序时,将会给浏览器带来很大的压力。Internet Explorer在内存管理方面表现的并不是很好,话句话说,在处理JavaScript和DHTML的操作时,很容易发生一系列的内存泄露问题。

主界面主要指标介绍:

1、Address:需要执行的URL地址,即需要进行测试的地址。

2、Auto Refresh:正在执行的URL将会自动进行刷新。在内存使用列表和图表中,你可以查看是否在你的程序中仍然存在内存泄露。“Auto Refresh”按钮将会变为“Stop”,点击“Stop”将会取消“自动刷新模式”。

3、Clear in use:已注册并正在工作的DOM元素列别将会被清空,实际上所有的元素将会在“Elements in use”对话框中被隐藏。

4、Show in use:显示所有正在使用的DOM元素。

5、Show leaks:显示所有到现在为止已发现的内存泄露问题,

6、Memory Samples List:这里将包括所有的内存样本。其中虚拟内存大小也包含在列表中。样本中红色表示内存使用增加,绿色表示内存使用减小,黑色表示与前一个内存样本相比,无变化。重新输入URL或进入自动刷新状态都将会清空此列表。

7、Usage:所占用内存,单位为:KB

8、Delta:与前一个内存样本相比,相差的内存占用量。

9、Avg:“Delta”的平均值,内存使用量中大的起伏将会导致不可预料的结果。

10、#inUse:已注册的DOM元素数量

11、#hidden:在“clear in use”中隐藏的DOM元素数量

12、Sloa/Fast/Paused:内存样本图像和列表的更新速度,Slow更新时长为5秒,Fast为1秒,Paused则暂停更新。

 

“In Use/Leak Dialog”界面中元素介绍:

1、#:自动为已注册的元素产生的序列号

2、doc:自动为已经注册的问题特别产生的序列号,其作用是当几个相同URL同时运行时可以辨别和查看。

3、Refs:所涉及到的元素数量

4、Tag:已注册元素的DOM节点名,例如TD/TR/DIV等。

5、ID:DOM元素的ID属性值。

6、Orphan:如果这一列的值为“YES”,则表明这个元素不附属于document.body中(即页面的BODY中)。在IE中,这种元素会导致内存泄露,应给予高度的关注。

7、outerHTML:显示输出地HTML。

8、New Item:表示为红色,显示新增加的项目。

   Increased refcount:表示为蓝色,项目不为新,但此项目涉及到的元素有增加。

   Decrease refcount:表示为绿色,项目不为新,但此项目涉及到的元素有减少。

\documentclass[12pt]{article} \usepackage{amsmath, amssymb} \usepackage{graphicx} \usepackage{geometry} \usepackage{setspace} \usepackage{caption} \usepackage{fancyhdr} \usepackage{titlesec} \geometry{a4paper, margin=1in} \onehalfspacing \titleformat{\section}{\large\bfseries}{\thesection}{1em}{} \titleformat{\subsection}{\normalsize\bfseries}{\thesubsection}{1em}{} \title{Sieve of Eratosthenes} \author{Zhang Hongwei} \date{December 2, 2025} \begin{document} \maketitle \begin{abstract} The Sieve of Eratosthenes is one of the oldest and most efficient algorithms for finding all prime numbers up to a given limit \( n \). This paper presents a comprehensive overview of its historical background, algorithmic principles, step-by-step execution, time and space complexity analysis, and comparisons with optimized variants such as the segmented sieve and Euler's linear sieve. With clear illustrations and mathematical derivations, this work aims to provide both beginners and practitioners with a solid understanding of this classical method in number theory and computer science. \end{abstract} \section{Introduction} Prime numbers have fascinated mathematicians for centuries due to their fundamental role in number theory and modern cryptography. An efficient way to generate all primes not exceeding a given integer \( n \) is essential in various computational tasks. Around 200 BCE, the Greek mathematician Eratosthenes devised an elegant algorithm—now known as the \textit{Sieve of Eratosthenes}—that systematically eliminates composite numbers from a list of integers, leaving only the primes. This algorithm remains widely used today due to its simplicity and effectiveness for small to medium ranges (typically \( n \leq 10^7 \)). It operates by iteratively marking the multiples of each discovered prime starting from 2. The unmarked numbers that remain are precisely the primes. Formally, given a positive integer \( n \), the goal is to output all prime numbers \( \leq n \). The time complexity is \( O(n \log \log n) \), and the space complexity is \( O(n) \), making it highly practical for many applications including education, primality testing pre-processing, and cryptographic key generation. \section{Algorithm Principle} A \textbf{prime number} is a natural number greater than 1 that has no positive divisors other than 1 and itself. A \textbf{composite number} has at least one additional divisor. The core idea of the Sieve of Eratosthenes is simple: \begin{quote} Start from the smallest prime, mark all its multiples as composite; move to the next unmarked number (which must be prime); repeat until \( \sqrt{n} \). \end{quote} Two critical optimizations make this method efficient: \subsection*{Why start marking from \( p^2 \)?} For a prime \( p \), any multiple \( k \cdot p \) with \( k < p \) must have already been marked by a smaller prime factor of \( k \). For example, \( 6 = 2 \times 3 \) is eliminated when processing \( p = 2 \). Thus, we begin marking from \( p^2 \), avoiding redundant operations. \subsection*{Why stop at \( \sqrt{n} \)?} Every composite number \( \mathrm{num} \) has at least one prime factor \( \leq \sqrt{\mathrm{num}} \). Suppose otherwise: let \( \mathrm{num} = a \times b \), where both \( a > \sqrt{\mathrm{num}} \) and \( b > \sqrt{\mathrm{num}} \). Then: \[ a \times b > \sqrt{\mathrm{num}} \cdot \sqrt{\mathrm{num}} = \mathrm{num}, \] which contradicts \( a \times b = \mathrm{num} \). Hence, at least one factor must be \( \leq \sqrt{\mathrm{num}} \). Therefore, checking primes up to \( \sqrt{n} \) suffices to eliminate all composites \( \leq n \). \section{Algorithm Steps} Let us illustrate the process for \( n = 100 \): \begin{enumerate} \item Create a list of integers from 2 to 100. \item Initialize a boolean array \texttt{prime[0..100]} with all values set to \texttt{True}. \item Set \texttt{prime[0]} and \texttt{prime[1]} to \texttt{False} (not primes). \item Let \( p = 2 \). If \texttt{prime[p]} is \texttt{True}, mark all multiples \( \geq p^2 = 4 \) as \texttt{False}. \item Find the next \( p \) such that \texttt{prime[p] == True}, and repeat step 4. \item Stop when \( p > \sqrt{100} = 10 \). \item All indices \( i \) with \texttt{prime[i] == True} are prime. \end{enumerate} \begin{figure}[h!] \centering \includegraphics[width=0.8\linewidth]{sieve_step.png} \begin{figure} \centering \includegraphics[width=0.5\linewidth]{Flowchart.jpg} \caption{Enter Caption} \label{fig:placeholder} \end{figure} \caption{Visualization of the sieving process: multiples of 2, 3, 5, and 7 are progressively removed. Remaining numbers are primes.} \label{fig:sieve} \end{figure} As shown in Figure~\ref{fig:sieve}, after eliminating multiples of 2, 3, 5, and 7, the remaining unmarked numbers are the primes below 100. \section{Complexity Analysis} \subsection{Time Complexity} Each prime \( p \) requires approximately \( \frac{n}{p} \) operations to mark its multiples. The total number of operations is roughly: \[ T(n) \approx \sum_{\substack{p \leq \sqrt{n} \\ p\ \text{prime}}} \frac{n}{p} = n \left( \frac{1}{2} + \frac{1}{3} + \frac{1}{5} + \cdots + \frac{1}{p_k} \right), \] where \( p_k \) is the largest prime \( \leq \sqrt{n} \). From analytic number theory, the sum of reciprocals of primes up to \( m \) grows asymptotically as \( \log \log m \). Setting \( m = \sqrt{n} \), we get: \[ \log \log \sqrt{n} = \log \left( \frac{1}{2} \log n \right) = \log \log n - \log 2. \] Thus, the overall time complexity is: \[ O(n \log \log n). \] \subsection{Space Complexity} We need a boolean array of size \( n+1 \), so the space complexity is \( O(n) \). \section{Variants and Comparison} \begin{table}[h!] \centering \caption{Comparison of prime-finding algorithms} \label{tab:comparison} \begin{tabular}{|l|c|c|l|} \hline \textbf{Algorithm} & \textbf{Time} & \textbf{Space} & \textbf{Use Case} \\ \hline Trial Division (per number) & $O(\sqrt{n})$ & $O(1)$ & Single prime check \\ Standard Sieve of Eratosthenes & $O(n \log \log n)$ & $O(n)$ & Small-medium scale \\ Segmented Sieve & $O(n \log \log n)$ & $O(\sqrt{n})$ & Large-scale ($n > 10^8$) \\ Euler’s Linear Sieve & $O(n)$ & $O(n)$ & High-performance batch \\ \hline \end{tabular} \end{table} \subsection{Improved Versions} \begin{itemize} \item \textbf{Segmented Sieve}: Divides the range into blocks, reducing memory usage to \( O(\sqrt{n}) \), suitable for very large \( n \). \item \textbf{Euler's Sieve (Linear Sieve)}: Ensures every composite is marked exactly once using the smallest prime factor, achieving \( O(n) \) time but with higher constant factors and poorer cache behavior. \end{itemize} \section{Conclusion and Outlook} The Sieve of Eratosthenes stands as a timeless example of algorithmic elegance and efficiency. Despite being over two millennia old, it remains relevant in modern computing. Its intuitive logic makes it ideal for teaching, while its performance suits real-world applications within moderate limits. \textbf{Recommendations:} \begin{itemize} \item Use standard sieve for $ n \leq 10^7 $ \item Apply trial division for individual checks \item Employ segmented sieve for $ n > 10^8 $ \item Consider Euler’s sieve for optimal speed in competitive programming \end{itemize} Future enhancements may involve parallelization across CPU cores or GPU acceleration. Nevertheless, the original sieve continues to serve as a foundational tool in algorithm design and number theory exploration. \end{document} 图片插入怎么回事
最新发布
12-03
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值