SlideShare a Scribd company logo
1 of 2
Download to read offline
Consider a binary search tree T with nodes containing the four fields key, left, right, p. and ht,
where key is an integer, left, and right are pointers to the two subtrees, p is a pointer to the parent
of the node, and ht is the height of the node (the maximum length of a path from this node to a
leaf). Design an algorithm for a procedure insert (T, x) that inserts to a binary searches tree T a
new node x (whose key is not in the tree yet), and updates lit fields accordingly. The function
should work in O(h) time, where h is the length of the access path.
Solution
Algorithm is implemented in C:
struct node
{
int key;
struct node *left, *right;
};
//function to create a new BST node
struct node *new_Node(int item)
{
struct node *tem = (struct node *)malloc(sizeof(struct node));
tem->key = item;
tem->left = tem->right = NULL;
return tem;
}
/INSERT PROCEDURE
/* Given key in BST,function to insert a new node. */
struct node* insert(struct node* T, int x)
{
/* If tree is empty then return a new node */
if (T == NULL) return new_Node(x);
/* else, repeat down the tree */
if (x < T->x)
T->left = insert(T->left, x);
else if (key > node->key)
T->right = insert(T->right, x);
return T;
}

More Related Content

Similar to Consider a binary search tree T with nodes containing the four fields.pdf

Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structuresNiraj Agarwal
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxBrianGHiNewmanv
 
I want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdfI want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdfbermanbeancolungak45
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfvishalateen
 
computer notes - Data Structures - 26
computer notes - Data Structures - 26computer notes - Data Structures - 26
computer notes - Data Structures - 26ecomputernotes
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdfaathiauto
 
You will create a Node class template- where the squareroot node is h.docx
You will create a Node class template- where the squareroot  node is h.docxYou will create a Node class template- where the squareroot  node is h.docx
You will create a Node class template- where the squareroot node is h.docxfarrahkur54
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdfaathmaproducts
 
(C++ exercise) 3. Implement a circular, doubly linked list with a ha.docx
(C++ exercise) 3. Implement a circular, doubly linked list with a ha.docx(C++ exercise) 3. Implement a circular, doubly linked list with a ha.docx
(C++ exercise) 3. Implement a circular, doubly linked list with a ha.docxajoy21
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfEricvtJFraserr
 
Write a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdfWrite a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdfhardjasonoco14599
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfankit11134
 
I am trying to fill out a program where the method definitions will b.docx
I am trying  to fill out a program where the method definitions will b.docxI am trying  to fill out a program where the method definitions will b.docx
I am trying to fill out a program where the method definitions will b.docxPhil4IDBrownh
 
Stack - PPT Slides.pptx-data sturutures and algorithanms
Stack - PPT Slides.pptx-data sturutures and algorithanmsStack - PPT Slides.pptx-data sturutures and algorithanms
Stack - PPT Slides.pptx-data sturutures and algorithanmsAdithaBuwaneka
 

Similar to Consider a binary search tree T with nodes containing the four fields.pdf (20)

Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
I want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdfI want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdf
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
 
computer notes - Data Structures - 26
computer notes - Data Structures - 26computer notes - Data Structures - 26
computer notes - Data Structures - 26
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
You will create a Node class template- where the squareroot node is h.docx
You will create a Node class template- where the squareroot  node is h.docxYou will create a Node class template- where the squareroot  node is h.docx
You will create a Node class template- where the squareroot node is h.docx
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
 
(C++ exercise) 3. Implement a circular, doubly linked list with a ha.docx
(C++ exercise) 3. Implement a circular, doubly linked list with a ha.docx(C++ exercise) 3. Implement a circular, doubly linked list with a ha.docx
(C++ exercise) 3. Implement a circular, doubly linked list with a ha.docx
 
Linked list
Linked listLinked list
Linked list
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
 
Write a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdfWrite a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdf
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Game Paper
Game PaperGame Paper
Game Paper
 
dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
I am trying to fill out a program where the method definitions will b.docx
I am trying  to fill out a program where the method definitions will b.docxI am trying  to fill out a program where the method definitions will b.docx
I am trying to fill out a program where the method definitions will b.docx
 
03-Lists.ppt
03-Lists.ppt03-Lists.ppt
03-Lists.ppt
 
Stack - PPT Slides.pptx-data sturutures and algorithanms
Stack - PPT Slides.pptx-data sturutures and algorithanmsStack - PPT Slides.pptx-data sturutures and algorithanms
Stack - PPT Slides.pptx-data sturutures and algorithanms
 

More from SIGMATAX1

Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdfBased on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdfSIGMATAX1
 
Comparecontrast the following classes of hormones by identifying thr.pdf
Comparecontrast the following classes of hormones by identifying thr.pdfComparecontrast the following classes of hormones by identifying thr.pdf
Comparecontrast the following classes of hormones by identifying thr.pdfSIGMATAX1
 
Why does the incidence of acute disease decrease with ageSoluti.pdf
Why does the incidence of acute disease decrease with ageSoluti.pdfWhy does the incidence of acute disease decrease with ageSoluti.pdf
Why does the incidence of acute disease decrease with ageSoluti.pdfSIGMATAX1
 
White eye color in Drosophila was discovered to be sex linked by Tho.pdf
White eye color in Drosophila was discovered to be sex linked by Tho.pdfWhite eye color in Drosophila was discovered to be sex linked by Tho.pdf
White eye color in Drosophila was discovered to be sex linked by Tho.pdfSIGMATAX1
 
Which of the following protons would you NOT expect to find embedded .pdf
Which of the following protons would you NOT expect to find embedded .pdfWhich of the following protons would you NOT expect to find embedded .pdf
Which of the following protons would you NOT expect to find embedded .pdfSIGMATAX1
 
Which of these characteristics distinguishes angiosperms from other .pdf
Which of these characteristics distinguishes angiosperms from other .pdfWhich of these characteristics distinguishes angiosperms from other .pdf
Which of these characteristics distinguishes angiosperms from other .pdfSIGMATAX1
 
Which of the following is MOST responsible for maintaining the doubl.pdf
Which of the following is MOST responsible for maintaining the doubl.pdfWhich of the following is MOST responsible for maintaining the doubl.pdf
Which of the following is MOST responsible for maintaining the doubl.pdfSIGMATAX1
 
What are the role of environmental factors on transpiration and h.pdf
What are the role of environmental factors on transpiration and h.pdfWhat are the role of environmental factors on transpiration and h.pdf
What are the role of environmental factors on transpiration and h.pdfSIGMATAX1
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
 
What is the need for a shadow page table (One or two brief sentences.pdf
What is the need for a shadow page table (One or two brief sentences.pdfWhat is the need for a shadow page table (One or two brief sentences.pdf
What is the need for a shadow page table (One or two brief sentences.pdfSIGMATAX1
 
What step of protein synthesis is shown in the figure elongation st.pdf
What step of protein synthesis is shown in the figure  elongation st.pdfWhat step of protein synthesis is shown in the figure  elongation st.pdf
What step of protein synthesis is shown in the figure elongation st.pdfSIGMATAX1
 
Water is forced through a contraction causing low pressure. The wat.pdf
Water is forced through a contraction causing low pressure. The wat.pdfWater is forced through a contraction causing low pressure. The wat.pdf
Water is forced through a contraction causing low pressure. The wat.pdfSIGMATAX1
 
Using a PIC 18 Write a time overflow interrupt routine that detects .pdf
Using a PIC 18 Write a time overflow interrupt routine that detects .pdfUsing a PIC 18 Write a time overflow interrupt routine that detects .pdf
Using a PIC 18 Write a time overflow interrupt routine that detects .pdfSIGMATAX1
 
The three types of mixtures are and The weak bond forming a bridge .pdf
The three types of mixtures are  and  The weak bond forming a bridge .pdfThe three types of mixtures are  and  The weak bond forming a bridge .pdf
The three types of mixtures are and The weak bond forming a bridge .pdfSIGMATAX1
 
Some commercial airplanes recirculate approximately 50 of the cabin .pdf
Some commercial airplanes recirculate approximately 50 of the cabin .pdfSome commercial airplanes recirculate approximately 50 of the cabin .pdf
Some commercial airplanes recirculate approximately 50 of the cabin .pdfSIGMATAX1
 
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdfSolve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdfSIGMATAX1
 
Required 1. Briefly describe different computer controls available .pdf
Required 1. Briefly describe different computer controls available .pdfRequired 1. Briefly describe different computer controls available .pdf
Required 1. Briefly describe different computer controls available .pdfSIGMATAX1
 
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdfa. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdfSIGMATAX1
 
Proponents of decentralized forms of socialism usually supportA co.pdf
Proponents of decentralized forms of socialism usually supportA co.pdfProponents of decentralized forms of socialism usually supportA co.pdf
Proponents of decentralized forms of socialism usually supportA co.pdfSIGMATAX1
 
Please convert the following C code to assembly Y86int i,j; ......pdf
Please convert the following C code to assembly Y86int i,j; ......pdfPlease convert the following C code to assembly Y86int i,j; ......pdf
Please convert the following C code to assembly Y86int i,j; ......pdfSIGMATAX1
 

More from SIGMATAX1 (20)

Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdfBased on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
 
Comparecontrast the following classes of hormones by identifying thr.pdf
Comparecontrast the following classes of hormones by identifying thr.pdfComparecontrast the following classes of hormones by identifying thr.pdf
Comparecontrast the following classes of hormones by identifying thr.pdf
 
Why does the incidence of acute disease decrease with ageSoluti.pdf
Why does the incidence of acute disease decrease with ageSoluti.pdfWhy does the incidence of acute disease decrease with ageSoluti.pdf
Why does the incidence of acute disease decrease with ageSoluti.pdf
 
White eye color in Drosophila was discovered to be sex linked by Tho.pdf
White eye color in Drosophila was discovered to be sex linked by Tho.pdfWhite eye color in Drosophila was discovered to be sex linked by Tho.pdf
White eye color in Drosophila was discovered to be sex linked by Tho.pdf
 
Which of the following protons would you NOT expect to find embedded .pdf
Which of the following protons would you NOT expect to find embedded .pdfWhich of the following protons would you NOT expect to find embedded .pdf
Which of the following protons would you NOT expect to find embedded .pdf
 
Which of these characteristics distinguishes angiosperms from other .pdf
Which of these characteristics distinguishes angiosperms from other .pdfWhich of these characteristics distinguishes angiosperms from other .pdf
Which of these characteristics distinguishes angiosperms from other .pdf
 
Which of the following is MOST responsible for maintaining the doubl.pdf
Which of the following is MOST responsible for maintaining the doubl.pdfWhich of the following is MOST responsible for maintaining the doubl.pdf
Which of the following is MOST responsible for maintaining the doubl.pdf
 
What are the role of environmental factors on transpiration and h.pdf
What are the role of environmental factors on transpiration and h.pdfWhat are the role of environmental factors on transpiration and h.pdf
What are the role of environmental factors on transpiration and h.pdf
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
What is the need for a shadow page table (One or two brief sentences.pdf
What is the need for a shadow page table (One or two brief sentences.pdfWhat is the need for a shadow page table (One or two brief sentences.pdf
What is the need for a shadow page table (One or two brief sentences.pdf
 
What step of protein synthesis is shown in the figure elongation st.pdf
What step of protein synthesis is shown in the figure  elongation st.pdfWhat step of protein synthesis is shown in the figure  elongation st.pdf
What step of protein synthesis is shown in the figure elongation st.pdf
 
Water is forced through a contraction causing low pressure. The wat.pdf
Water is forced through a contraction causing low pressure. The wat.pdfWater is forced through a contraction causing low pressure. The wat.pdf
Water is forced through a contraction causing low pressure. The wat.pdf
 
Using a PIC 18 Write a time overflow interrupt routine that detects .pdf
Using a PIC 18 Write a time overflow interrupt routine that detects .pdfUsing a PIC 18 Write a time overflow interrupt routine that detects .pdf
Using a PIC 18 Write a time overflow interrupt routine that detects .pdf
 
The three types of mixtures are and The weak bond forming a bridge .pdf
The three types of mixtures are  and  The weak bond forming a bridge .pdfThe three types of mixtures are  and  The weak bond forming a bridge .pdf
The three types of mixtures are and The weak bond forming a bridge .pdf
 
Some commercial airplanes recirculate approximately 50 of the cabin .pdf
Some commercial airplanes recirculate approximately 50 of the cabin .pdfSome commercial airplanes recirculate approximately 50 of the cabin .pdf
Some commercial airplanes recirculate approximately 50 of the cabin .pdf
 
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdfSolve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
 
Required 1. Briefly describe different computer controls available .pdf
Required 1. Briefly describe different computer controls available .pdfRequired 1. Briefly describe different computer controls available .pdf
Required 1. Briefly describe different computer controls available .pdf
 
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdfa. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
 
Proponents of decentralized forms of socialism usually supportA co.pdf
Proponents of decentralized forms of socialism usually supportA co.pdfProponents of decentralized forms of socialism usually supportA co.pdf
Proponents of decentralized forms of socialism usually supportA co.pdf
 
Please convert the following C code to assembly Y86int i,j; ......pdf
Please convert the following C code to assembly Y86int i,j; ......pdfPlease convert the following C code to assembly Y86int i,j; ......pdf
Please convert the following C code to assembly Y86int i,j; ......pdf
 

Recently uploaded

e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxMarlene Maheu
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MysoreMuleSoftMeetup
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 

Recently uploaded (20)

e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 

Consider a binary search tree T with nodes containing the four fields.pdf

  • 1. Consider a binary search tree T with nodes containing the four fields key, left, right, p. and ht, where key is an integer, left, and right are pointers to the two subtrees, p is a pointer to the parent of the node, and ht is the height of the node (the maximum length of a path from this node to a leaf). Design an algorithm for a procedure insert (T, x) that inserts to a binary searches tree T a new node x (whose key is not in the tree yet), and updates lit fields accordingly. The function should work in O(h) time, where h is the length of the access path. Solution Algorithm is implemented in C: struct node { int key; struct node *left, *right; }; //function to create a new BST node struct node *new_Node(int item) { struct node *tem = (struct node *)malloc(sizeof(struct node)); tem->key = item; tem->left = tem->right = NULL; return tem; } /INSERT PROCEDURE /* Given key in BST,function to insert a new node. */ struct node* insert(struct node* T, int x) { /* If tree is empty then return a new node */ if (T == NULL) return new_Node(x); /* else, repeat down the tree */ if (x < T->x) T->left = insert(T->left, x); else if (key > node->key) T->right = insert(T->right, x);