Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
krahets committed Mar 22, 2024
1 parent 7570cef commit cb751c0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ int main() {
count = logRecur(n);
cout << "对数阶(递归实现)的操作数量 = " << count << endl;

count = linearLogRecur((n);
count = linearLogRecur(n);
cout << "线性对数阶(递归实现)的操作数量 = " << count << endl;

count = factorialRecur(n);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class time_complexity {
void Algorithm(int n) {
int a = 1; // +0(技巧 1)
a += n; // +0(技巧 1)
// +n(技巧 2)
// +n(技巧 2)
for (int i = 0; i < 5 * n + 1; i++) {
Console.WriteLine(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int expRecur(int n) {
int logarithmic(int n) {
int count = 0;
while (n > 1) {
n = n / 2;
n = n ~/ 2;
count++;
}
return count;
Expand All @@ -99,13 +99,13 @@ int logarithmic(int n) {
/* 对数阶(递归实现) */
int logRecur(int n) {
if (n <= 1) return 0;
return logRecur(n / 2) + 1;
return logRecur(n ~/ 2) + 1;
}

/* 线性对数阶 */
int linearLogRecur(int n) {
if (n <= 1) return 1;
int count = linearLogRecur(n / 2) + linearLogRecur(n / 2);
int count = linearLogRecur(n ~/ 2) + linearLogRecur(n ~/ 2);
for (var i = 0; i < n; i++) {
count++;
}
Expand Down

0 comments on commit cb751c0

Please sign in to comment.