Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mario BinaryTree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Abitur 2024
Mario BinaryTree
Commits
1d273c14
Commit
1d273c14
authored
2 years ago
by
tim
Browse files
Options
Downloads
Patches
Plain Diff
ausgabe hinzugefügt
parent
5ad2592a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Ahne.java
+4
-0
4 additions, 0 deletions
Ahne.java
Main.java
+43
-1
43 additions, 1 deletion
Main.java
with
47 additions
and
1 deletion
Ahne.java
+
4
−
0
View file @
1d273c14
...
...
@@ -6,4 +6,8 @@ public class Ahne{
name
=
pName
;
geschlecht
=
pGeschlecht
;
}
public
String
toString
(){
return
(
name
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Main.java
+
43
−
1
View file @
1d273c14
...
...
@@ -2,7 +2,7 @@ public class Main{
private
BinaryTree
<
Ahne
>
lisasAhnenbaum
;
public
void
Main
(){
public
Main
(){
BinaryTree
<
Ahne
>
b1
=
new
BinaryTree
<
Ahne
>(
new
Ahne
(
"Jacueline Bouvier"
,
'w'
));
BinaryTree
<
Ahne
>
b2
=
new
BinaryTree
<
Ahne
>(
new
Ahne
(
"Clancy Bouvier"
,
'm'
));
BinaryTree
<
Ahne
>
b3
=
new
BinaryTree
<
Ahne
>(
new
Ahne
(
"Marge Simpson"
,
'w'
),
b1
,
b2
);
...
...
@@ -11,4 +11,46 @@ public class Main{
BinaryTree
<
Ahne
>
b6
=
new
BinaryTree
<
Ahne
>(
new
Ahne
(
"Homer Simpson"
,
'm'
),
b4
,
b5
);
lisasAhnenbaum
=
new
BinaryTree
<
Ahne
>(
new
Ahne
(
"Lisa Simpson"
,
'w'
),
b3
,
b6
);
}
public
void
ausgabeAhnenbaum
(){
System
.
out
.
println
(
"\npreorder:"
);
preorder
(
lisasAhnenbaum
);
System
.
out
.
println
(
"\npostorder:"
);
postorder
(
lisasAhnenbaum
);
System
.
out
.
println
(
"\ninorder:"
);
inorder
(
lisasAhnenbaum
);
}
public
void
preorder
(
BinaryTree
<
Ahne
>
tree
){
preorderIntern
(
tree
);
}
private
void
preorderIntern
(
BinaryTree
<
Ahne
>
tree
){
if
(!
tree
.
isEmpty
()){
System
.
out
.
println
(
tree
.
getContent
());
preorderIntern
(
tree
.
getLeftTree
());
preorderIntern
(
tree
.
getRightTree
());
}
}
public
void
postorder
(
BinaryTree
<
Ahne
>
tree
){
postorderIntern
(
tree
);
}
private
void
postorderIntern
(
BinaryTree
<
Ahne
>
tree
){
if
(!
tree
.
isEmpty
()){
postorderIntern
(
tree
.
getLeftTree
());
postorderIntern
(
tree
.
getRightTree
());
System
.
out
.
println
(
tree
.
getContent
());
}
}
public
void
inorder
(
BinaryTree
<
Ahne
>
tree
){
inorderIntern
(
tree
);
}
private
void
inorderIntern
(
BinaryTree
<
Ahne
>
tree
){
if
(!
tree
.
isEmpty
()){
inorderIntern
(
tree
.
getLeftTree
());
System
.
out
.
println
(
tree
.
getContent
());
inorderIntern
(
tree
.
getRightTree
());
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment