Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4d4bafa

Browse files
program to traverse each level line by line
1 parent db6cbde commit 4d4bafa

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

‎Data Structures/Trees/Binary Trees/LevelOrderChangedPath.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ void levelOrderChanged(node *root)
3232
sz = q.size();
3333

3434
// Do a normal level order traversal
35-
for (int i = 0; i < sz; i++) {
35+
for (int i = 0; i < sz; i++)
36+
{
3637

3738
temp = q.front();
3839
q.pop();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include<iostream>
2+
3+
using namespace std;
4+
5+
struct node{
6+
7+
int data;
8+
struct node *left,*right;
9+
};
10+
11+
void PrintLevelLinebyLine()

‎VirtualInheritenceAndDiamondProblem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class Animal{
1515
}
1616
};
1717

18-
class Tiger : public Animal{
18+
class Tiger : virtualpublic Animal{
1919
public:
2020
Tiger() {
2121
cout<<"Tiger constructor called"<<endl;
2222
}
2323
};
2424

2525

26-
class Lion : public Animal{
26+
class Lion : virtual public Animal{
2727

2828
public:
2929

@@ -44,8 +44,8 @@ class Liger: public Tiger, private Lion {
4444

4545

4646
int main() {
47-
Liger l;
48-
l.getAnimal(); //error if virtual inheritence is not used-'getAnimal' is ambiguous, as compiler will not know from which instance of Tiger or Lion will be used to call
47+
Liger l;
48+
// l.getAnimal(); //error if virtual inheritence is not used-'getAnimal' is ambiguous, as compiler will not know from which instance of Tiger or Lion will be used to call
4949
//getAnimal() of Animal class
5050

5151
// when virtual inheritence is not used-

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /