SlideShare a Scribd company logo
1 of 9
Download to read offline
Electrical Engineering Department
CS243L: Data Structures and Algorithms
Course Instructor: Momina Azam Dated: January 17, 2022
Lab Engineer: Muhammad Usama Riaz
Semester: 3rd
Session: 2020-2024 Batch: BSEE2020
Lab. 12 Binary Search Tree
Name Roll No Lab ReportMarks/100 Total Marks
(Scaled out of 10)
MUHAMMAD UMER
SHAKIR
BSEE20075
Checked on:
Signature:
12.1 Objective
The goal of this handout is to observe and implement the basic of a data structure Binary search
tree.
12.2 Equipment and Component
Component
Description
Value Quantity
Computer Available in lab 1
11.3 Conduct of Lab
1. Students are required to perform this experiment individually.
2. In case the lab experiment is not understood, the students are advised to seek help from
the courseinstructor, lab engineers, assigned teaching assistants (TA) and lab attendants.
11.4 Theory and Background
Binary Search Tree is a node-based binary tree data structure which has the following
properties: The left sub-tree of a node contains only nodes with keys lesser than the node's
key. The right sub-tree of a node contains only nodes with keys greater than the node's key.
Lab Tasks [10 Mark]
Q.1 Binary Search Tree
The structure of a node in the tree:
Every node in the tree must have the provision to hold:
1. data for the user
2. A pointer that can point to the node that is the left child
3. A pointer that can point to the node that is the right child
Implement a class called BSTree (for Binary Search Tree)
Data member:
Must be a Node pointer that points to the root Node.
Interface:
Add Function:
1. The function takes data as an argument.
2. It must create the node on the heap using new. Both pointers of the new Node left and right ones
will point to NULL.
3. Start from the root Node
4. Compare key of the new node with the key at this node.
5. If key at this Node is larger go to the Node pointed to by the right pointer of this Node.
6. If key at this Node is smaller go to the Node pointed to by the left pointer of this Node.
7. At each Node follow the steps from step 4 till you hit a pointer that points to NULL.
8. Attach the new Node you have created to this pointer.
When the tree is empty be sure to make the root pointer in the BSTree object point to the first node
you add.
#include<iostream>
using namespace std;
class NODE
{
public:
int INFORMATION;
NODE *LEFT;
NODE *RIGHT;
}*root;
class Binarysearchtree
{
public:
void insert(NODE *, NODE *);
void display(NODE*, int);
Binarysearchtree ()
{
root = NULL;
}
};
void Binarysearchtree::insert(NODE *tree, NODE *newnode)
{
if (root == NULL)
{
root = new NODE;
root->INFORMATION= newnode->INFORMATION;
root->LEFT = NULL;
root->RIGHT = NULL;
cout<<"Root Node is Added"<<endl;
return;
}
if (tree->INFORMATION == newnode->INFORMATION)
{
cout<<"Element already in the BS tree:"<<endl;
return;
}
if (tree->INFORMATION > newnode->INFORMATION)
{
if (tree->LEFT != NULL)
{
insert(tree->LEFT, newnode);
}
else
{
tree->LEFT = newnode;
(tree->LEFT)->LEFT= NULL;
(tree->LEFT)->RIGHT = NULL;
cout<<"Node Added To Left of bts"<<endl;
return;
}
}
else
{
if (tree->RIGHT != NULL)
{
insert(tree->RIGHT, newnode);
}
else
{
tree->RIGHT = newnode;
(tree->RIGHT)->LEFT = NULL;
(tree->RIGHT)->RIGHT = NULL;
cout<<"Node Added To Right of bts"<<endl;
return;
}
}
}
void Binarysearchtree::display(NODE *ptr, int level)
{
int i;
if (ptr != NULL)
{
display(ptr->RIGHT, level+1);
cout<<endl;
if (ptr == root)
cout<<"Root->: ";
else
{
for (i = 0;i < level;i++)
cout<<" ";
}
cout<<ptr->INFORMATION;
display(ptr->LEFT, level+1);
}
}
int main()
{
int number, num;
Binarysearchtree bst;
NODE *temp;
while (1)
{
cout<<"-----------------"<<endl;
cout<<"1:Insert Element in the BST: "<<endl;
cout<<"2:Display BST :"<<endl;
cout<<"3:Quit"<<endl;
cout<<"-----------------"<<endl;
cout<<"Enter your choice number : ";
cin>>number;
switch(number)
{
case 1:
temp = new NODE;
cout<<"Enter the number to be inserted : ";
cin>>temp->INFORMATION;
bst.insert(root, temp);
case 2:
cout<<"Display BST:"<<endl;
bst.display(root,1);
cout<<endl;
break;
case 3:
exit(1);
default:
cout<<"Wrong choice"<<endl;
}
}
}
Student Name Registration# Batch: EE-2020
Assessment Rubrics
Method: Lab reports and instructor observation during lab sessions.
Outcome assessed:
a. Ability to conduct experiments, as well as to analyze and interpret data (P)
b. Ability to function on multi-disciplinary teams (A)
c. Ability to use the techniques, skills, and modern engineering tools necessary for engineering practice (P)
Performance metric Mapping (task no.
and description)
Max
marks
Exceeds expectation Meets expectation Does not meet expectation Obtained
marks
1. Realization of
experiment (a)
1 Functionality 40 Executes without errors excellent
user prompts, good use of
symbols, spacing in output.
Through testing has been
completed (45-41)
Executes without errors, user
prompts are understandable,
minimum use of symbols or spacing
in output. Some testing has been
completed (40-21)
Does not execute due to syntax errors,
runtime errors, user prompts are
misleading or non-existent. No testing has
been completed (20-0)
2. Teamwork (b) 1 Group
Performance
5 Actively engages and cooperates
with other group member(s) in
effective manner (5-4)
Cooperates with other group
member(s) in a reasonable manner
but conduct can be improved (3-2)
Distracts or discourages other group
members from conducting the experiment
(1-0)
3. Conducting
experiment (a, c)
1 On Spot
Changes
10 Able to make changes (5-4) Partially able to make changes (3-2) Unable to make changes (1-0)
2 Viva 10 Answered all questions (5-4) Few incorrect answers (3-2) Unable to answer all questions (1-0)
4. Laboratory safety
and disciplinary rules
(a)
1 Code
commenting
5 Observes lab safety rules;
adheres to the lab disciplinary
guidelines aptly (5-4)
Generally, observes safety rules and
disciplinary guidelines with minor
lapses (3-2)
Disregards lab safety and disciplinary rules
(1-0)
5. Data collection (c) 1 Code Structure 5 Excellent use of white space,
creatively organized work,
excellent use of variables and
constants, correct identifiers for
constants, No line-wrap (5-4)
Includes name, and assignment,
white space makes the program
fairly easy to read. Title, organized
work, good use of variables (3-2)
Poor use of white space (indentation, blank
lines) making code hard to read,
disorganized and messy (1-0)
6. Data analysis (a, c) 1 Algorithm 20 Solution is efficient, easy to
understand, and maintain (5-4)
A logical solution that is easy to
follow but it is not the most
efficient (3-2)
A difficult and inefficient solution (1-0)
7. Computer use (c) 1 Documentation 5 Timely documented (5-4) Late documented (3-2) Not documented (1-0)
Max Marks (total): 100 Obtained Marks (Total):
Lab Engineer Signature: ________________________

More Related Content

What's hot

Ds06 linked list- insert a node after a given node
Ds06   linked list-  insert a node after a given nodeDs06   linked list-  insert a node after a given node
Ds06 linked list- insert a node after a given node
jyoti_lakhani
 
DocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUNDDocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUND
Xulang Wan
 

What's hot (18)

Introduction to python programming 2
Introduction to python programming   2Introduction to python programming   2
Introduction to python programming 2
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
 
Ds06 linked list- insert a node after a given node
Ds06   linked list-  insert a node after a given nodeDs06   linked list-  insert a node after a given node
Ds06 linked list- insert a node after a given node
 
Python functions part11
Python functions  part11Python functions  part11
Python functions part11
 
Chap 11(pointers)
Chap 11(pointers)Chap 11(pointers)
Chap 11(pointers)
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
Data Structure
Data StructureData Structure
Data Structure
 
Arrays searching-sorting
Arrays searching-sortingArrays searching-sorting
Arrays searching-sorting
 
Chapter 11 ds
Chapter 11 dsChapter 11 ds
Chapter 11 ds
 
DocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUNDDocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUND
 
Cpphtp4 ppt 03
Cpphtp4 ppt 03Cpphtp4 ppt 03
Cpphtp4 ppt 03
 
Data structures Lecture 5
Data structures Lecture 5Data structures Lecture 5
Data structures Lecture 5
 
Control statements
Control statementsControl statements
Control statements
 
Mean, Median, Mode And Range by Mary T
Mean, Median, Mode And Range by Mary TMean, Median, Mode And Range by Mary T
Mean, Median, Mode And Range by Mary T
 
introduction
introductionintroduction
introduction
 
Singly & Circular Linked list
Singly & Circular Linked listSingly & Circular Linked list
Singly & Circular Linked list
 
Ijetcas14 483
Ijetcas14 483Ijetcas14 483
Ijetcas14 483
 

Similar to Lab12 dsa bsee20075

Please write the C++ code that would display the exact same output a.pdf
Please write the C++ code that would display the exact same output a.pdfPlease write the C++ code that would display the exact same output a.pdf
Please write the C++ code that would display the exact same output a.pdf
amarndsons
 
Given a newly created Binary Search Tree with the following numerica.pdf
Given a newly created Binary Search Tree with the following numerica.pdfGiven a newly created Binary Search Tree with the following numerica.pdf
Given a newly created Binary Search Tree with the following numerica.pdf
hadpadrrajeshh
 
main.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdf
main.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdfmain.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdf
main.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdf
pratikradia365
 
Ds 111011055724-phpapp01
Ds 111011055724-phpapp01Ds 111011055724-phpapp01
Ds 111011055724-phpapp01
Getachew Ganfur
 
BSTNode.Java Node class used for implementing the BST. .pdf
BSTNode.Java   Node class used for implementing the BST. .pdfBSTNode.Java   Node class used for implementing the BST. .pdf
BSTNode.Java Node class used for implementing the BST. .pdf
info189835
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
maxinesmith73660
 
Page 3SECTION 1. Algorithm Analysis [1 pt per prompt = 12 poi.docx
Page 3SECTION 1.  Algorithm Analysis [1 pt per prompt = 12 poi.docxPage 3SECTION 1.  Algorithm Analysis [1 pt per prompt = 12 poi.docx
Page 3SECTION 1. Algorithm Analysis [1 pt per prompt = 12 poi.docx
bunyansaturnina
 

Similar to Lab12 dsa bsee20075 (20)

Lecture 7-BinarySearchTrees.ppt
Lecture 7-BinarySearchTrees.pptLecture 7-BinarySearchTrees.ppt
Lecture 7-BinarySearchTrees.ppt
 
Please write the C++ code that would display the exact same output a.pdf
Please write the C++ code that would display the exact same output a.pdfPlease write the C++ code that would display the exact same output a.pdf
Please write the C++ code that would display the exact same output a.pdf
 
Given a newly created Binary Search Tree with the following numerica.pdf
Given a newly created Binary Search Tree with the following numerica.pdfGiven a newly created Binary Search Tree with the following numerica.pdf
Given a newly created Binary Search Tree with the following numerica.pdf
 
main.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdf
main.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdfmain.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdf
main.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdf
 
Ds 111011055724-phpapp01
Ds 111011055724-phpapp01Ds 111011055724-phpapp01
Ds 111011055724-phpapp01
 
Seo Expert course in Pakistan
Seo Expert course in PakistanSeo Expert course in Pakistan
Seo Expert course in Pakistan
 
BSTNode.Java Node class used for implementing the BST. .pdf
BSTNode.Java   Node class used for implementing the BST. .pdfBSTNode.Java   Node class used for implementing the BST. .pdf
BSTNode.Java Node class used for implementing the BST. .pdf
 
Binary tree
Binary treeBinary tree
Binary tree
 
Unit 1 LINEAR DATA STRUCTURES
Unit 1  LINEAR DATA STRUCTURESUnit 1  LINEAR DATA STRUCTURES
Unit 1 LINEAR DATA STRUCTURES
 
Linked List.pptx
Linked List.pptxLinked List.pptx
Linked List.pptx
 
Lo27
Lo27Lo27
Lo27
 
05
0505
05
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
 
Binary searchtrees
Binary searchtreesBinary searchtrees
Binary searchtrees
 
linkedlistwith animations.ppt
linkedlistwith animations.pptlinkedlistwith animations.ppt
linkedlistwith animations.ppt
 
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
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
 
ds 4Linked lists.ppt
ds 4Linked lists.pptds 4Linked lists.ppt
ds 4Linked lists.ppt
 
Page 3SECTION 1. Algorithm Analysis [1 pt per prompt = 12 poi.docx
Page 3SECTION 1.  Algorithm Analysis [1 pt per prompt = 12 poi.docxPage 3SECTION 1.  Algorithm Analysis [1 pt per prompt = 12 poi.docx
Page 3SECTION 1. Algorithm Analysis [1 pt per prompt = 12 poi.docx
 
Data structure week y 4
Data structure week y 4Data structure week y 4
Data structure week y 4
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

Lab12 dsa bsee20075

  • 1. Electrical Engineering Department CS243L: Data Structures and Algorithms Course Instructor: Momina Azam Dated: January 17, 2022 Lab Engineer: Muhammad Usama Riaz Semester: 3rd Session: 2020-2024 Batch: BSEE2020 Lab. 12 Binary Search Tree Name Roll No Lab ReportMarks/100 Total Marks (Scaled out of 10) MUHAMMAD UMER SHAKIR BSEE20075 Checked on: Signature:
  • 2. 12.1 Objective The goal of this handout is to observe and implement the basic of a data structure Binary search tree. 12.2 Equipment and Component Component Description Value Quantity Computer Available in lab 1 11.3 Conduct of Lab 1. Students are required to perform this experiment individually. 2. In case the lab experiment is not understood, the students are advised to seek help from the courseinstructor, lab engineers, assigned teaching assistants (TA) and lab attendants. 11.4 Theory and Background Binary Search Tree is a node-based binary tree data structure which has the following properties: The left sub-tree of a node contains only nodes with keys lesser than the node's key. The right sub-tree of a node contains only nodes with keys greater than the node's key. Lab Tasks [10 Mark] Q.1 Binary Search Tree The structure of a node in the tree: Every node in the tree must have the provision to hold: 1. data for the user 2. A pointer that can point to the node that is the left child 3. A pointer that can point to the node that is the right child Implement a class called BSTree (for Binary Search Tree) Data member: Must be a Node pointer that points to the root Node. Interface: Add Function: 1. The function takes data as an argument. 2. It must create the node on the heap using new. Both pointers of the new Node left and right ones
  • 3. will point to NULL. 3. Start from the root Node 4. Compare key of the new node with the key at this node. 5. If key at this Node is larger go to the Node pointed to by the right pointer of this Node. 6. If key at this Node is smaller go to the Node pointed to by the left pointer of this Node. 7. At each Node follow the steps from step 4 till you hit a pointer that points to NULL. 8. Attach the new Node you have created to this pointer. When the tree is empty be sure to make the root pointer in the BSTree object point to the first node you add.
  • 4. #include<iostream> using namespace std; class NODE { public: int INFORMATION; NODE *LEFT; NODE *RIGHT; }*root; class Binarysearchtree { public: void insert(NODE *, NODE *); void display(NODE*, int); Binarysearchtree () { root = NULL; } }; void Binarysearchtree::insert(NODE *tree, NODE *newnode) { if (root == NULL) { root = new NODE; root->INFORMATION= newnode->INFORMATION; root->LEFT = NULL; root->RIGHT = NULL; cout<<"Root Node is Added"<<endl; return; } if (tree->INFORMATION == newnode->INFORMATION) {
  • 5. cout<<"Element already in the BS tree:"<<endl; return; } if (tree->INFORMATION > newnode->INFORMATION) { if (tree->LEFT != NULL) { insert(tree->LEFT, newnode); } else { tree->LEFT = newnode; (tree->LEFT)->LEFT= NULL; (tree->LEFT)->RIGHT = NULL; cout<<"Node Added To Left of bts"<<endl; return; } } else { if (tree->RIGHT != NULL) { insert(tree->RIGHT, newnode); } else { tree->RIGHT = newnode; (tree->RIGHT)->LEFT = NULL; (tree->RIGHT)->RIGHT = NULL;
  • 6. cout<<"Node Added To Right of bts"<<endl; return; } } } void Binarysearchtree::display(NODE *ptr, int level) { int i; if (ptr != NULL) { display(ptr->RIGHT, level+1); cout<<endl; if (ptr == root) cout<<"Root->: "; else { for (i = 0;i < level;i++) cout<<" "; } cout<<ptr->INFORMATION; display(ptr->LEFT, level+1); } } int main() { int number, num; Binarysearchtree bst; NODE *temp; while (1) { cout<<"-----------------"<<endl; cout<<"1:Insert Element in the BST: "<<endl; cout<<"2:Display BST :"<<endl; cout<<"3:Quit"<<endl;
  • 7. cout<<"-----------------"<<endl; cout<<"Enter your choice number : "; cin>>number; switch(number) { case 1: temp = new NODE; cout<<"Enter the number to be inserted : "; cin>>temp->INFORMATION; bst.insert(root, temp); case 2: cout<<"Display BST:"<<endl; bst.display(root,1); cout<<endl; break; case 3: exit(1); default: cout<<"Wrong choice"<<endl; } } }
  • 8.
  • 9. Student Name Registration# Batch: EE-2020 Assessment Rubrics Method: Lab reports and instructor observation during lab sessions. Outcome assessed: a. Ability to conduct experiments, as well as to analyze and interpret data (P) b. Ability to function on multi-disciplinary teams (A) c. Ability to use the techniques, skills, and modern engineering tools necessary for engineering practice (P) Performance metric Mapping (task no. and description) Max marks Exceeds expectation Meets expectation Does not meet expectation Obtained marks 1. Realization of experiment (a) 1 Functionality 40 Executes without errors excellent user prompts, good use of symbols, spacing in output. Through testing has been completed (45-41) Executes without errors, user prompts are understandable, minimum use of symbols or spacing in output. Some testing has been completed (40-21) Does not execute due to syntax errors, runtime errors, user prompts are misleading or non-existent. No testing has been completed (20-0) 2. Teamwork (b) 1 Group Performance 5 Actively engages and cooperates with other group member(s) in effective manner (5-4) Cooperates with other group member(s) in a reasonable manner but conduct can be improved (3-2) Distracts or discourages other group members from conducting the experiment (1-0) 3. Conducting experiment (a, c) 1 On Spot Changes 10 Able to make changes (5-4) Partially able to make changes (3-2) Unable to make changes (1-0) 2 Viva 10 Answered all questions (5-4) Few incorrect answers (3-2) Unable to answer all questions (1-0) 4. Laboratory safety and disciplinary rules (a) 1 Code commenting 5 Observes lab safety rules; adheres to the lab disciplinary guidelines aptly (5-4) Generally, observes safety rules and disciplinary guidelines with minor lapses (3-2) Disregards lab safety and disciplinary rules (1-0) 5. Data collection (c) 1 Code Structure 5 Excellent use of white space, creatively organized work, excellent use of variables and constants, correct identifiers for constants, No line-wrap (5-4) Includes name, and assignment, white space makes the program fairly easy to read. Title, organized work, good use of variables (3-2) Poor use of white space (indentation, blank lines) making code hard to read, disorganized and messy (1-0) 6. Data analysis (a, c) 1 Algorithm 20 Solution is efficient, easy to understand, and maintain (5-4) A logical solution that is easy to follow but it is not the most efficient (3-2) A difficult and inefficient solution (1-0) 7. Computer use (c) 1 Documentation 5 Timely documented (5-4) Late documented (3-2) Not documented (1-0) Max Marks (total): 100 Obtained Marks (Total): Lab Engineer Signature: ________________________