Skip to content

Commit cb0d269

Browse files
author
dhruv
committedDec 13, 2020
Initial commit
1 parent b0a2610 commit cb0d269

File tree

2 files changed

+62
-22
lines changed

2 files changed

+62
-22
lines changed
 

‎Graph.java

+20-22
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,24 @@ public static void main(String[] args){
3636
System.out.println(n1.connections);
3737

3838

39-
/*
40-
Scanner scan = new Scanner(System.in);
41-
System.out.println("Enter the number of vertices: ");
42-
int num = scan.nextInt();
43-
44-
Node[] vertices = new Node[num];
45-
46-
for (int i=0; i<num; i++){
47-
vertices[i] = new Node();
48-
vertices[i].data = Integer.toString(i);
49-
System.out.println("Enter connections of " + i + " vertex: ");
50-
String inp = scan.next();
51-
vertices[i].connect(inp);
52-
vertices[i].show();
53-
54-
}
55-
56-
*/
57-
//for (int i; i<num;i++){
58-
// vertices[i].
59-
//}
60-
}
39+
// Scanner scan = new Scanner(System.in);
40+
// System.out.println("Enter the number of vertices: ");
41+
// int num = scan.nextInt();
42+
//
43+
// Node[] vertices = new Node[num];
44+
//
45+
// for (int i=0; i<num; i++){
46+
// vertices[i] = new Node();
47+
// vertices[i].data = Integer.toString(i);
48+
// System.out.println("Enter connections of " + i + " vertex: ");
49+
// String inp = scan.next();
50+
// vertices[i].connect(inp);
51+
// vertices[i].show();
52+
//
53+
// }
54+
//
55+
// for (int i; i<num;i++){
56+
// vertices[i].
57+
// }
58+
// }
6159
}
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
public class MultithreadingQuestion1 {
2+
public static void main(String[] args) {
3+
MyThreadUsingInterface1 one = new MyThreadUsingInterface1();
4+
MyThreadUsingInterface2 two = new MyThreadUsingInterface2();
5+
6+
Thread t1 = new Thread(MyThreadUsingInterface1);
7+
Thread t2 = new Thread(MyThreadUsingInterface2);
8+
}
9+
}
10+
11+
class MyThreadUsingInterface1 implements Runnable{
12+
public void run(){
13+
int arr[] = Helper.Fibonacci(10);
14+
for (int i =0; i<10; i++){
15+
System.out.print(arr[i] + '\t');
16+
}
17+
}
18+
}
19+
20+
class MyThreadUsingInterface2 implements Runnable{
21+
public void run(){
22+
int arr[] = Helper.reversePrinter(10);
23+
}
24+
}
25+
26+
class Helper{
27+
public static int[] Fibonacci(int n){
28+
int[] arr = new int[n];
29+
arr[0] = 0;
30+
arr[1] = 1;
31+
for (int i = 2; i<n;i++){
32+
arr[i] = arr[i-2] + arr[i-1];
33+
}
34+
return arr;
35+
}
36+
37+
public static void reversePrinter(int n){
38+
for (int i =n; i>0; i--){
39+
System.out.println(i);
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)
Please sign in to comment.