SlideShare a Scribd company logo
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

Introduction to python programming 2
Introduction to python programming   2Introduction to python programming   2
Introduction to python programming 2
Giovanni Della Lunga
 
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
Rai University
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
Giovanni Della Lunga
 
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
 
Python functions part11
Python functions  part11Python functions  part11
Python functions part11
Vishal Dutt
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
Hanif Durad
 
Data Structure
Data StructureData Structure
Data Structure
Karthikeyan A K
 
Arrays searching-sorting
Arrays searching-sortingArrays searching-sorting
Arrays searching-sorting
Ajharul Abedeen
 
Chapter 11 ds
Chapter 11 dsChapter 11 ds
Chapter 11 ds
Hanif Durad
 
DocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUNDDocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUNDXulang Wan
 
Cpphtp4 ppt 03
Cpphtp4 ppt 03Cpphtp4 ppt 03
Cpphtp4 ppt 03
sanya6900
 
Data structures Lecture 5
Data structures Lecture 5Data structures Lecture 5
Data structures Lecture 5
AzharIqbal710687
 
Control statements
Control statementsControl statements
Control statements
Pramod Rathore
 
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
Julian Charter
 
introduction
introductionintroduction
introduction
Mohamed Elsayed
 
Singly & Circular Linked list
Singly & Circular Linked listSingly & Circular Linked list
Singly & Circular Linked list
Khulna University of Engineering & Tecnology
 

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

Lecture 7-BinarySearchTrees.ppt
Lecture 7-BinarySearchTrees.pptLecture 7-BinarySearchTrees.ppt
Lecture 7-BinarySearchTrees.ppt
DrBashirMSaad
 
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-phpapp01Getachew Ganfur
 
Seo Expert course in Pakistan
Seo Expert course in PakistanSeo Expert course in Pakistan
Seo Expert course in Pakistan
ssuserb2c86f
 
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
 
Binary tree
Binary treeBinary tree
Binary tree
Maria Saleem
 
Unit 1 LINEAR DATA STRUCTURES
Unit 1  LINEAR DATA STRUCTURESUnit 1  LINEAR DATA STRUCTURES
Unit 1 LINEAR DATA STRUCTURES
Usha Mahalingam
 
Linked List.pptx
Linked List.pptxLinked List.pptx
Linked List.pptx
PoonamPatil120
 
Lo27
Lo27Lo27
Lo27
lksoo
 
05
0505
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
Afaq Mansoor Khan
 
linkedlistwith animations.ppt
linkedlistwith animations.pptlinkedlistwith animations.ppt
linkedlistwith animations.ppt
MuhammadShafi89
 
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
BrianGHiNewmanv
 
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
 
ds 4Linked lists.ppt
ds 4Linked lists.pptds 4Linked lists.ppt
ds 4Linked lists.ppt
AlliVinay1
 
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
 
Data structure week y 4
Data structure week y 4Data structure week y 4
Data structure week y 4
karmuhtam
 

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

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 

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: ________________________