-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter.java
More file actions
66 lines (56 loc) · 925 Bytes
/
Counter.java
File metadata and controls
66 lines (56 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
public class Counter
{
public static void main(String args[])
{
Scanner sc = new Scnner(System.in);
int n = sc.nextInt();
System.out.println(constSearch(n));
System.out.println(logSearch(n));
System.out.println(linearSearch(n));
System.out.println(nlogSearch(n));
System.out.println(polySearch(n));
System.out.println(expSoearch(n));
}
public int constSearch(int n)
{
return 1;
}
public int logSearch(int n)
{
int counter=0;
for(int i=0;i<Math.log10(n);i++)
{
counter++;
}
return counter;
}
public int linearSearch(int n)
{
return n;
}
public int nlogSearch
{
int counter=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<Math.log10(n);j++)
{
counter++;
}
}
return counter;
}
public int polySearch(int n)
{
return 0;
}
public int expoSearch(int n)
{
int counter=0;
for(int i=0;i<Math.pow(2,n);i++)
{
counter++;
}
return counter;
}
}