Skip to content

Commit 6547b38

Browse files
committed
Rate of Growths Update
Rate of Growths Update
1 parent 0e667d0 commit 6547b38

14 files changed

+260
-0
lines changed
748 Bytes
Binary file not shown.
743 Bytes
Binary file not shown.
727 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
770 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*Copyright (c) Dec 25, 2014 CareerMonk Publications and others.
2+
* E-Mail : info@careermonk.com
3+
* Creation Date : 2015-01-10 06:15:46
4+
* Last modification : 2006-05-31
5+
by : Narasimha Karumanchi
6+
* File Name : LogNComplexityDown.java
7+
* Book Title : Data Structures And Algorithms Made In Java
8+
* Warranty : This software is provided "as is" without any
9+
* warranty; without even the implied warranty of
10+
* merchantability or fitness for a particular purpose.
11+
*
12+
*/
13+
14+
15+
package chapter01introduction;
16+
17+
public class LogNComplexityDown {
18+
19+
public static void main(String[] args) {
20+
int n = 19;
21+
System.out.println(logNUp(n));
22+
}
23+
24+
public static int logNUp(int n){
25+
int count = 0;
26+
for (int i = n; i>0;){
27+
count ++;
28+
i = i / 2;
29+
}
30+
return count;
31+
}
32+
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*Copyright (c) Dec 25, 2014 CareerMonk Publications and others.
2+
* E-Mail : info@careermonk.com
3+
* Creation Date : 2015-01-10 06:15:46
4+
* Last modification : 2006-05-31
5+
by : Narasimha Karumanchi
6+
* File Name : LogNComplexityUp.java
7+
* Book Title : Data Structures And Algorithms Made In Java
8+
* Warranty : This software is provided "as is" without any
9+
* warranty; without even the implied warranty of
10+
* merchantability or fitness for a particular purpose.
11+
*
12+
*/
13+
14+
15+
package chapter01introduction;
16+
17+
public class LogNComplexityUp {
18+
19+
public static void main(String[] args) {
20+
// TODO Auto-generated method stub
21+
int n = 19;
22+
System.out.println(logNUp(n));
23+
}
24+
25+
public static int logNUp(int n){
26+
int count = 0;
27+
for (int i = 1; i<n;){
28+
count ++;
29+
i = i *2;
30+
}
31+
return count;
32+
}
33+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*Copyright (c) Dec 25, 2014 CareerMonk Publications and others.
2+
* E-Mail : info@careermonk.com
3+
* Creation Date : 2015-01-10 06:15:46
4+
* Last modification : 2006-05-31
5+
by : Narasimha Karumanchi
6+
* File Name : NComplexity.java
7+
* Book Title : Data Structures And Algorithms Made In Java
8+
* Warranty : This software is provided "as is" without any
9+
* warranty; without even the implied warranty of
10+
* merchantability or fitness for a particular purpose.
11+
*
12+
*/
13+
14+
15+
package chapter01introduction;
16+
17+
public class NComplexity {
18+
19+
public static void main(String[] args) {
20+
// TODO Auto-generated method stub
21+
int n = 19;
22+
System.out.println(orderN(n));
23+
}
24+
public static int orderN(int n){
25+
int count = 0;
26+
for (int i = 1; i<n;){
27+
count ++;
28+
i = i+1;
29+
}
30+
return count;
31+
}
32+
}

0 commit comments

Comments
 (0)