Skip to content

Commit 9ab4dc3

Browse files
committed
#Modification 30
1 parent 5ec507a commit 9ab4dc3

File tree

91 files changed

+367
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+367
-93
lines changed
File renamed without changes.

oopsabstraction/Audi.java renamed to abstraction/Audi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package oopsabstraction;
1+
package abstraction;
22

33
//Audi Class
44
public class Audi extends Car{
File renamed without changes.

oopsabstraction/Car.java renamed to abstraction/Car.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package oopsabstraction;
1+
package abstraction;
22

33
public abstract class Car {
44
public abstract void accelerate();
File renamed without changes.

abstraction/RepairShop.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package abstraction;
2+
3+
public class RepairShop {
4+
5+
public static void repairCar(Car car) {
6+
System.out.println("Car is repaired");
7+
}
8+
9+
public static void repairCar(Car...Audi) {
10+
System.out.println("Car is repaired");
11+
}
12+
13+
public static void main(String[] args) {
14+
WagonR wagonR = new WagonR();
15+
Audi audi = new Audi();
16+
17+
repairCar(wagonR);
18+
repairCar(audi);
19+
}
20+
}
File renamed without changes.

abstraction/WagonR.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package abstraction;
2+
3+
public class WagonR extends Car{
4+
5+
@Override
6+
public void accelerate() {
7+
System.out.println("WagonR is accelerating");
8+
}
9+
10+
@Override
11+
public void apply_break() {
12+
System.out.println("break is applied in WagonR");
13+
}
14+
}

binaryTree/BT_Problem_10.java

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,47 @@
55
* The right view of a binary tree, is set of nodes visible when tree is visited from rights side
66
* between two end nodes.
77
*/
8+
class Max_level{
9+
int max_level;
10+
}
811
public class BT_Problem_10 {
912

1013
Node root;
11-
static int max_level = 0;
1214

13-
void leftViewUtil(Node node, int level) {
15+
Max_level max_level = new Max_level();
16+
17+
void rightViewUtil(Node node, int level, Max_level max_level) {
1418

1519
if(node == null)
1620
return;
1721

18-
if(max_level < level) {
19-
System.out.print(" " + node.data);
20-
max_level = level;
22+
if(max_level.max_level < level) {
23+
System.out.print(node.data + " " );
24+
max_level.max_level = level;
2125
}
2226

23-
27+
rightViewUtil(node.right, level+1,max_level);
28+
rightViewUtil(node.left, level+1,max_level);
29+
}
30+
31+
void rightView() {
32+
rightView(root);
2433
}
34+
35+
void rightView(Node node) {
36+
rightViewUtil(node, 1, max_level);
37+
}
38+
2539
public static void main(String[] args) {
40+
BT_Problem_10 tree = new BT_Problem_10();
41+
tree.root = new Node(12);
42+
tree.root.left = new Node(10);
43+
tree.root.right = new Node(30);
44+
tree.root.right.left = new Node(25);
45+
tree.root.right.right = new Node(40);
46+
47+
tree.rightView();
2648

27-
2849
}
2950

3051
}

binaryTree/BT_Problem_15.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import java.util.*;
33
import java.util.Map.Entry;
44
/*
5-
* Problem Title :- Diagnol Traversal of a Binary tree
5+
* Problem Title :- Daignol Traversal of a Binary tree
66
*/
77
public class BT_Problem_15 {
88

0 commit comments

Comments
 (0)