SlideShare a Scribd company logo
1 of 5
Download to read offline
Program pohon Biner (Tree)
Bosca simbolon
1282024
Sistem informasi
#include <stdio.h>
#include <malloc.h>
#define nil NULL
//stuct nod
struct nod
{
struct nod *left;
char data;
struct nod *right;
};
typedef struct nod NOD;
typedef NOD POKOK;
NOD *NodBaru(char item)
{
NOD *n;
n = (NOD*) malloc(sizeof(NOD));
if(n != NULL)
{
n->data = item;
n->left = NULL;
n->right = NULL;
}
return n;
}
void BinaPokok(POKOK **T)
{
*T = NULL;
}
typedef enum { FALSE = 0, TRUE = 1} BOOL;
BOOL PokokKosong(POKOK *T)
{
return((BOOL)(T == NULL));
}
void TambahNod(NOD **p, char item)
{
NOD *n;
n = NodBaru(item);
*p = n;
}
void preorder(POKOK *T)
{
if(!PokokKosong(T))
{
printf("%c ", T->data);
preorder(T->left);
preorder(T->right);
}
}
void inorder(POKOK *T)
{
if(!PokokKosong(T))
{
inorder(T->left);
printf("%c ", T->data);
inorder(T->right);
}
}
void postorder(POKOK *T)
{
if(!PokokKosong(T))
{
postorder(T->left);
postorder(T->right);
printf("%c ", T->data);
}
}
int main()
{
POKOK *pohon;
char buah;
BinaPokok(&pohon);
TambahNod(&pohon, buah = 'B');
TambahNod(&pohon->left, buah = 'O');
TambahNod(&pohon->left->right, buah = 'S');
TambahNod(&pohon->right, buah = 'K');
TambahNod(&pohon->right->right, buah = 'A');
TambahNod(&pohon->right->right->left, buah = 'S');
TambahNod(&pohon->right->right->right, buah = 'I');
TambahNod(&pohon->right->right->right->left, buah = 'M');
TambahNod(&pohon->right->right->right->left->right, buah = 'B');
TambahNod(&pohon->right->right->right->left->right->right, buah = 'O');
TambahNod(&pohon->right->right->right->left->right->right->right, buah = 'L');
TambahNod(&pohon->right->right->right->left->right->right->right->right, buah = 'O');
TambahNod(&pohon->right->right->right->left->right->right->right->right->right, buah = 'N');
printf("Tampilan secara Preorder: ");
preorder(pohon);
printf("nTampilan secara Inorder: ");
inorder(pohon);
printf("nTampilan secara Postorder: ");
postorder(pohon);
printf("nn");
return 0;
}
Screenshoot Running
Preorder : B O S K A S I M B O L O N
O
S
O
B
I
A
K
L
B
M
S
N

More Related Content

What's hot

Brief intro to clojure
Brief intro to clojureBrief intro to clojure
Brief intro to clojureRoy Rutto
 
Garbage collector in python
Garbage collector in pythonGarbage collector in python
Garbage collector in pythonIbrahim Kasim
 
Fixing Web Data in Production
Fixing Web Data in ProductionFixing Web Data in Production
Fixing Web Data in ProductionAaron Knight
 
Class list data structure
Class list data structureClass list data structure
Class list data structureKatang Isip
 
Herding types with Scala macros
Herding types with Scala macrosHerding types with Scala macros
Herding types with Scala macrosMarina Sigaeva
 
Android mix Java and C++
Android mix Java and C++Android mix Java and C++
Android mix Java and C++Maksym Davydov
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineersvarun arora
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3Simon Su
 
20160616技術會議
20160616技術會議20160616技術會議
20160616技術會議Jason Kuan
 
Why learn new programming languages
Why learn new programming languagesWhy learn new programming languages
Why learn new programming languagesJonas Follesø
 
Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Platonov Sergey
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changeshayato
 

What's hot (20)

MongoDB
MongoDBMongoDB
MongoDB
 
Brief intro to clojure
Brief intro to clojureBrief intro to clojure
Brief intro to clojure
 
Garbage collector in python
Garbage collector in pythonGarbage collector in python
Garbage collector in python
 
Container adapters
Container adaptersContainer adapters
Container adapters
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Fixing Web Data in Production
Fixing Web Data in ProductionFixing Web Data in Production
Fixing Web Data in Production
 
Class list data structure
Class list data structureClass list data structure
Class list data structure
 
Herding types with Scala macros
Herding types with Scala macrosHerding types with Scala macros
Herding types with Scala macros
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
C++ programs
C++ programsC++ programs
C++ programs
 
Typelevel summit
Typelevel summitTypelevel summit
Typelevel summit
 
OOXX
OOXXOOXX
OOXX
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
 
Android mix Java and C++
Android mix Java and C++Android mix Java and C++
Android mix Java and C++
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 
20160616技術會議
20160616技術會議20160616技術會議
20160616技術會議
 
Why learn new programming languages
Why learn new programming languagesWhy learn new programming languages
Why learn new programming languages
 
Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 

Viewers also liked

Eliminasi gauss-jordan
Eliminasi gauss-jordanEliminasi gauss-jordan
Eliminasi gauss-jordanRenol Doang
 
Modul maple untuk metnum 2014
Modul maple untuk metnum 2014Modul maple untuk metnum 2014
Modul maple untuk metnum 2014Samuel Pinto'o
 
Metode transportasi
Metode transportasiMetode transportasi
Metode transportasisuparman11
 
PENYELESAIAN MASALAH PENUGASAN DENGAN METODE HUNGARIAN
PENYELESAIAN MASALAH PENUGASAN DENGAN METODE HUNGARIANPENYELESAIAN MASALAH PENUGASAN DENGAN METODE HUNGARIAN
PENYELESAIAN MASALAH PENUGASAN DENGAN METODE HUNGARIANFeronica Romauli
 

Viewers also liked (6)

Rangkuman i
Rangkuman iRangkuman i
Rangkuman i
 
Eliminasi gauss-jordan
Eliminasi gauss-jordanEliminasi gauss-jordan
Eliminasi gauss-jordan
 
Eliminasi Gauss
Eliminasi GaussEliminasi Gauss
Eliminasi Gauss
 
Modul maple untuk metnum 2014
Modul maple untuk metnum 2014Modul maple untuk metnum 2014
Modul maple untuk metnum 2014
 
Metode transportasi
Metode transportasiMetode transportasi
Metode transportasi
 
PENYELESAIAN MASALAH PENUGASAN DENGAN METODE HUNGARIAN
PENYELESAIAN MASALAH PENUGASAN DENGAN METODE HUNGARIANPENYELESAIAN MASALAH PENUGASAN DENGAN METODE HUNGARIAN
PENYELESAIAN MASALAH PENUGASAN DENGAN METODE HUNGARIAN
 

Similar to Program Binary Tree (Tree

Doublylinklist
DoublylinklistDoublylinklist
Doublylinklistritu1806
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfgalagirishp
 
1. Add a breadth-first (level-order) traversal function to the binar.pdf
1. Add a breadth-first (level-order) traversal function to the binar.pdf1. Add a breadth-first (level-order) traversal function to the binar.pdf
1. Add a breadth-first (level-order) traversal function to the binar.pdfarjuncp10
 
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docxtodd991
 
ItemNodeh include ltiostreamgt include ltstring.pdf
ItemNodeh    include ltiostreamgt include ltstring.pdfItemNodeh    include ltiostreamgt include ltstring.pdf
ItemNodeh include ltiostreamgt include ltstring.pdfacmefit
 
i nsert+in+ link list
i nsert+in+ link listi nsert+in+ link list
i nsert+in+ link listEAJAJAhamed
 
I have a Programming is Binary Tree Search (BTS) for strings with po.pdf
I have a Programming is Binary Tree Search (BTS) for strings with po.pdfI have a Programming is Binary Tree Search (BTS) for strings with po.pdf
I have a Programming is Binary Tree Search (BTS) for strings with po.pdfARCHANASTOREKOTA
 
To create a node for a binary search tree (BTNode, ) and to create a .pdf
To create a node for a binary search tree (BTNode, ) and to create a .pdfTo create a node for a binary search tree (BTNode, ) and to create a .pdf
To create a node for a binary search tree (BTNode, ) and to create a .pdfbhim1213
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of listElavarasi K
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureZarghamullahShah
 
Given the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfGiven the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfillyasraja7
 
Implement a function TNode copy_tree(TNode t) that creates a copy .pdf
Implement a function TNode copy_tree(TNode t) that creates a copy .pdfImplement a function TNode copy_tree(TNode t) that creates a copy .pdf
Implement a function TNode copy_tree(TNode t) that creates a copy .pdffeetshoemart
 
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfimport java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfshaktisinhgandhinaga
 

Similar to Program Binary Tree (Tree (20)

Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
 
1. Add a breadth-first (level-order) traversal function to the binar.pdf
1. Add a breadth-first (level-order) traversal function to the binar.pdf1. Add a breadth-first (level-order) traversal function to the binar.pdf
1. Add a breadth-first (level-order) traversal function to the binar.pdf
 
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
 
ItemNodeh include ltiostreamgt include ltstring.pdf
ItemNodeh    include ltiostreamgt include ltstring.pdfItemNodeh    include ltiostreamgt include ltstring.pdf
ItemNodeh include ltiostreamgt include ltstring.pdf
 
i nsert+in+ link list
i nsert+in+ link listi nsert+in+ link list
i nsert+in+ link list
 
I have a Programming is Binary Tree Search (BTS) for strings with po.pdf
I have a Programming is Binary Tree Search (BTS) for strings with po.pdfI have a Programming is Binary Tree Search (BTS) for strings with po.pdf
I have a Programming is Binary Tree Search (BTS) for strings with po.pdf
 
Linked lists
Linked listsLinked lists
Linked lists
 
To create a node for a binary search tree (BTNode, ) and to create a .pdf
To create a node for a binary search tree (BTNode, ) and to create a .pdfTo create a node for a binary search tree (BTNode, ) and to create a .pdf
To create a node for a binary search tree (BTNode, ) and to create a .pdf
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
 
Lab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdfLab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdf
 
Linked lists
Linked listsLinked lists
Linked lists
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structure
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 
Given the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfGiven the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdf
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
137 Lab-2.2.pdf
137 Lab-2.2.pdf137 Lab-2.2.pdf
137 Lab-2.2.pdf
 
Implement a function TNode copy_tree(TNode t) that creates a copy .pdf
Implement a function TNode copy_tree(TNode t) that creates a copy .pdfImplement a function TNode copy_tree(TNode t) that creates a copy .pdf
Implement a function TNode copy_tree(TNode t) that creates a copy .pdf
 
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfimport java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
 

Recently uploaded

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Recently uploaded (20)

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Program Binary Tree (Tree

  • 1. Program pohon Biner (Tree) Bosca simbolon 1282024 Sistem informasi #include <stdio.h> #include <malloc.h> #define nil NULL //stuct nod struct nod { struct nod *left; char data; struct nod *right; }; typedef struct nod NOD; typedef NOD POKOK; NOD *NodBaru(char item) { NOD *n; n = (NOD*) malloc(sizeof(NOD)); if(n != NULL) { n->data = item; n->left = NULL; n->right = NULL; }
  • 2. return n; } void BinaPokok(POKOK **T) { *T = NULL; } typedef enum { FALSE = 0, TRUE = 1} BOOL; BOOL PokokKosong(POKOK *T) { return((BOOL)(T == NULL)); } void TambahNod(NOD **p, char item) { NOD *n; n = NodBaru(item); *p = n; } void preorder(POKOK *T) { if(!PokokKosong(T)) { printf("%c ", T->data); preorder(T->left); preorder(T->right); } } void inorder(POKOK *T) { if(!PokokKosong(T)) {
  • 3. inorder(T->left); printf("%c ", T->data); inorder(T->right); } } void postorder(POKOK *T) { if(!PokokKosong(T)) { postorder(T->left); postorder(T->right); printf("%c ", T->data); } } int main() { POKOK *pohon; char buah; BinaPokok(&pohon); TambahNod(&pohon, buah = 'B'); TambahNod(&pohon->left, buah = 'O'); TambahNod(&pohon->left->right, buah = 'S'); TambahNod(&pohon->right, buah = 'K'); TambahNod(&pohon->right->right, buah = 'A'); TambahNod(&pohon->right->right->left, buah = 'S'); TambahNod(&pohon->right->right->right, buah = 'I'); TambahNod(&pohon->right->right->right->left, buah = 'M'); TambahNod(&pohon->right->right->right->left->right, buah = 'B'); TambahNod(&pohon->right->right->right->left->right->right, buah = 'O'); TambahNod(&pohon->right->right->right->left->right->right->right, buah = 'L');
  • 4. TambahNod(&pohon->right->right->right->left->right->right->right->right, buah = 'O'); TambahNod(&pohon->right->right->right->left->right->right->right->right->right, buah = 'N'); printf("Tampilan secara Preorder: "); preorder(pohon); printf("nTampilan secara Inorder: "); inorder(pohon); printf("nTampilan secara Postorder: "); postorder(pohon); printf("nn"); return 0; } Screenshoot Running
  • 5. Preorder : B O S K A S I M B O L O N O S O B I A K L B M S N