中文版简介: 跳转
English version intro: GoTo
一个轻量级 C++ 程序,实现从英文文本文件中提取单词、统计词频,并生成 按字母升序 和 按词频降序 两种格式的词汇表。程序采用随机基准的快速排序优化排序效率与稳定性,适用于算法实验、文本词频分析学习场景。
Algorithm-Design-Practice-Experiment/
├── Input.txt # 待处理的英文文本文件
├── main.cpp # 核心源码文件
└── main.exe # 打包成的可执行文件
In mathematics and computer science, an algorithm is a self-contained step-by-step set of operations to be performed. Algorithms exist that perform calculation, data processing, and automated reasoning.
An algorithm is an effective method that can be expressed within a finite amount of space and time and in a well-defined formal language for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that,
.....
| 单词 | 频率 |
|---|---|
| a | 15 |
| algorithm | 5 |
| algorithms | 10 |
| ambiguities | 1 |
| ambiguous | 1 |
| amount | 1 |
| an | 7 |
| and | 12 |
| ...... |
时间复杂度(快速排序):平均 (O(nlog n)),最差O(n^2)
A lightweight C++ program that extracts words from English text files, counts word frequencies, and generates two types of vocabulary lists: sorted alphabetically in ascending order and sorted by frequency in descending order. The program uses quick sort with a random pivot to optimize sorting efficiency and stability, making it suitable for algorithm experiments and text frequency analysis learning scenarios.
Algorithm-Design-Practice-Experiment/
├── Input.txt # English text file to be processed
├── main.cpp # Core source code file
└── main.exe # Compiled executable file
In mathematics and computer science, an algorithm is a self-contained step-by-step set of operations to be performed. Algorithms exist that perform calculation, data processing, and automated reasoning.
An algorithm is an effective method that can be expressed within a finite amount of space and time and in a well-defined formal language for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that,
.....
| Word | Frequency |
|---|---|
| a | 15 |
| algorithm | 5 |
| algorithms | 10 |
| ambiguities | 1 |
| ambiguous | 1 |
| amount | 1 |
| an | 7 |
| and | 12 |
| ...... |
Time complexity (Quick Sort): Average (O(nlog n)), worst-case (O(n^2))