This document provides information about a lab experiment on binary search trees conducted by students of the Electrical Engineering Department. It includes the objective, equipment used, conduct of the lab, theory background, and tasks assigned as part of the lab report. Students were evaluated based on their ability to realize the experiment, work as part of a team, make changes during the lab, answer questions, follow safety procedures, organize their code, analyze data, and document their work. The highest scoring students were able to complete the experiment without errors, engage cooperatively with others, make changes easily, answer all questions, and produce efficient and well-documented solutions.
For this project, students in Mrs. Beile's learning center math class were tasked with creating a Powerpoint presentation that explained how to solve a math problem. The students were expected to select a math concept they were struggling with themselves and pretend they were explaining the concept to a friend. By going through the process, the students were able to develop mastery and reinforce the concept for themselves. Everyone did a fantastic job!
In this playlist
https://youtube.com/playlist?list=PLT...
I'll illustrate algorithms and data structures course, and implement the data structures using java programming language.
the playlist language is arabic.
The Topics:
--------------------
1- Arrays
2- Linear and Binary search
3- Linked List
4- Recursion
5- Algorithm analysis
6- Stack
7- Queue
8- Binary search tree
9- Selection sort
10- Insertion sort
11- Bubble sort
12- merge sort
13- Quick sort
14- Graphs
15- Hash table
16- Binary Heaps
Reference : Object-Oriented Data Structures Using Java - Third Edition by NELL DALE, DANEIEL T.JOYCE and CHIP WEIMS
Slides is owned by College of Computing & Information Technology
King Abdulaziz University, So thanks alot for these great materials
Please write the C++ code that would display the exact same output a.pdfamarndsons
Please write the C++ code that would display the exact same output as provided. Thank you.
main.cpp
#include "TreeNode.h"
//GIVEN
void inorderTraversal(TreeNode * root);
//TODO
TreeNode * search(TreeNode * node,int data);
//GIVEN
void insert(TreeNode * node,int data);
//GIVEN
bool isNull(TreeNode * node){
return node==nullptr;
}
int main() {
// create the root, gets set to null
TreeNode * root;
// create the roor and set the data of root to 5
root= new TreeNode(5);
//create two additional nodes with data values 10 and 3
// these will go to the right and left of root respectively
TreeNode * ten= new TreeNode(10);
TreeNode * three= new TreeNode(3);
//connect ten to the right of root (which has data 5)
root->setRight(ten);
//connect three to the left of root (which has data 5)
root->setLeft(three);
// note this can also be done as
//root.setRight(new TreeNode(10));
//root.setLeft(new TreeNode(3);)
// add two more nodes
//the first has data value 7. So to keep the tree in insorted order, it should get attached as the
left node of ten
// the second has data value 4. So to keep the tree in insorted order, it should get attached as the
right node of three
ten->addLeft(7);
three->addRight(4);
std::cout<<"**************************************\n";
std::cout<<"Printing the Inorder Traversal\n";
inorderTraversal(root);
std::cout<<"**************************************\n";
std::cout<<"Searching for Node \n";
TreeNode* result = search(root,4);
if (result!=nullptr){
std::cout<<"Found "<getData()<<"\n";
}
else
std::cout<<"Not Found "<<4<<"\n";
result = search(root,1);
if (result!=nullptr){
std::cout<<"Found "<getData()<<"\n";
}
else
std::cout<<"Not Found "<<1<<"\n";
std::cout<<"**************************************\n";
std::cout<<"Inserting 6\n";
insert(root,6);
std::cout<<"**************************************\n";
std::cout<<"Printing the Inorder Traversal\n";
inorderTraversal(root);
}
// uses recursion
void inorderTraversal(TreeNode * node){
// exit case
if (isNull(node)) return;
if (node->isLeaf()){
std::cout<<"Printing Leaf Node "<getData()<<"\n";
return;}
// reached a node with no left, so print the node and travel right
if (!isNull(node->getLeft()))
// if there is a left path, then travel further on that
inorderTraversal(node->getLeft());
std::cout<<"Printing Node "<getData()<<"\n";
// save and travel the right path of the current node being processed
inorderTraversal(node->getRight());
}
// uses recursion
//TODO
TreeNode * search(TreeNode * node, int data){
// if the node is null return the null ptr
//if this nodes data equals the search date return found
// if not, if the left tree exists and search data less than
//this nodes data return the result of recursive all to search with left pointer
// if no left tree, but right tree exists and search data greater than
//this nodes data return the result of recursive all to search with right pointer
// if both above conditions not true return null ptr
}
//uses recursion
void insert(TreeNode * node,int .
Given a newly created Binary Search Tree with the following numerica.pdfhadpadrrajeshh
Given a newly created Binary Search Tree with the following numerical key input sequence
(from left to right): 9, 4, 12, 7, 5, 2, 20, 14, 11, 13, 19, 16, 17, 42, 24
a.) We are asked to add a function Position lowestKey(const Position& v) const to the class
SearchTree.
Function prototype: Position lowestKey(const Position& v);
input argument: position of the starting node in the binary search tree to calculate from. For the
whole tree this would be the position for the root of the tree.
return value: position of the node having the lowest key value.
i. Describe strategy with reasonings and examples to convince that it will work.
ii. Implement the function using C++ and show the source code listing.
b) We are also asked to add a function Position highestKey(const Position& v) const to the class
SearchTree.
Function prototype: Position highestKey(const Position& v) const;
input argument: position of the node in the binary search tree to calculate from. For the whole
tree this would be the position for the root of the tree.
return value: position of the node having the highest key value.
i. Describe strategy with reasonings and examples to convince that it will work.
ii. Implement the function using C++ and show the source code listing.
Solution
#include
#include
/* A binary tree node has data, pointer to left child
and a pointer to right child */
struct node
{
int data;
struct node* left;
struct node* right;
};
/* Helper function that allocates a new node
with the given data and NULL left and right
pointers. */
struct node* newNode(int data)
{
struct node* node = (struct node*)
malloc(sizeof(struct node));
node->data = data;
node->left = NULL;
node->right = NULL;
return(node);
}
/* Give a binary search tree and a number,
inserts a new node with the given number in
the correct place in the tree. Returns the new
root pointer which the caller should then use
(the standard trick to avoid using reference
parameters). */
struct node* insert(struct node* node, int data)
{
/* 1. If the tree is empty, return a new,
single node */
if (node == NULL)
return(newNode(data));
else
{
/* 2. Otherwise, recur down the tree */
if (data <= node->data)
node->left = insert(node->left, data);
else
node->right = insert(node->right, data);
/* return the (unchanged) node pointer */
return node;
}
}
/* Given a non-empty binary search tree,
return the minimum data value found in that
tree. Note that the entire tree does not need
to be searched. */
int minValue(struct node* node) {
struct node* current = node;
/* loop down to find the leftmost leaf */
while (current->left != NULL) {
current = current->left;
}
return(current->data);
}
/* Driver program to test sameTree function*/
int main()
{
struct node* root = NULL;
root = insert(root, 4);
insert(root, 2);
insert(root, 1);
insert(root, 3);
insert(root, 6);
insert(root, 5);
printf(\"\ Minimum value in BST is %d\", minValue(root));
getchar();
return 0;
}
#include
#include
/* A binary tree node has data, pointer to left child
.
main.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdfpratikradia365
main.cpp
#include "TreeNode.h"
//GIVEN
void inorderTraversal(TreeNode * root);
//TODO
TreeNode * search(TreeNode * node,int data);
//GIVEN
void insert(TreeNode * node,int data);
//GIVEN
bool isNull(TreeNode * node){
return node==nullptr;
}
int main() {
// create the root, gets set to null
TreeNode * root;
// create the roor and set the data of root to 5
root= new TreeNode(5);
//create two additional nodes with data values 10 and 3
// these will go to the right and left of root respectively
TreeNode * ten= new TreeNode(10);
TreeNode * three= new TreeNode(3);
//connect ten to the right of root (which has data 5)
root->setRight(ten);
//connect three to the left of root (which has data 5)
root->setLeft(three);
// note this can also be done as
//root.setRight(new TreeNode(10));
//root.setLeft(new TreeNode(3);)
// add two more nodes
//the first has data value 7. So to keep the tree in insorted order, it should get attached as the left
node of ten
// the second has data value 4. So to keep the tree in insorted order, it should get attached as the
right node of three
ten->addLeft(7);
three->addRight(4);
std::cout<<"**************************************\n";
std::cout<<"Printing the Inorder Traversal\n";
inorderTraversal(root);
std::cout<<"**************************************\n";
std::cout<<"Searching for Node \n";
TreeNode* result = search(root,4);
if (result!=nullptr){
std::cout<<"Found "<getData()<<"\n";
}
else
std::cout<<"Not Found "<<4<<"\n";
result = search(root,1);
if (result!=nullptr){
std::cout<<"Found "<getData()<<"\n";
}
else
std::cout<<"Not Found "<<1<<"\n";
std::cout<<"**************************************\n";
std::cout<<"Inserting 6\n";
insert(root,6);
std::cout<<"**************************************\n";
std::cout<<"Printing the Inorder Traversal\n";
inorderTraversal(root);
}
// uses recursion
void inorderTraversal(TreeNode * node){
// exit case
if (isNull(node)) return;
if (node->isLeaf()){
std::cout<<"Printing Leaf Node "<getData()<<"\n";
return;}
// reached a node with no left, so print the node and travel right
if (!isNull(node->getLeft()))
// if there is a left path, then travel further on that
inorderTraversal(node->getLeft());
std::cout<<"Printing Node "<getData()<<"\n";
// save and travel the right path of the current node being processed
inorderTraversal(node->getRight());
}
// uses recursion
//TODO
TreeNode * search(TreeNode * node, int data){
// if the node is null return the null ptr
//if this nodes data equals the search date return found
// if not, if the left tree exists and search data less than
//this nodes data return the result of recursive all to search with left pointer
// if no left tree, but right tree exists and search data greater than
//this nodes data return the result of recursive all to search with right pointer
// if both above conditions not true return null ptr
}
//uses recursion
void insert(TreeNode * node,int data){
if (node->getData()==data)
return;
else if(datagetData()){
if (!isNull(node->getLeft.
For this project, students in Mrs. Beile's learning center math class were tasked with creating a Powerpoint presentation that explained how to solve a math problem. The students were expected to select a math concept they were struggling with themselves and pretend they were explaining the concept to a friend. By going through the process, the students were able to develop mastery and reinforce the concept for themselves. Everyone did a fantastic job!
In this playlist
https://youtube.com/playlist?list=PLT...
I'll illustrate algorithms and data structures course, and implement the data structures using java programming language.
the playlist language is arabic.
The Topics:
--------------------
1- Arrays
2- Linear and Binary search
3- Linked List
4- Recursion
5- Algorithm analysis
6- Stack
7- Queue
8- Binary search tree
9- Selection sort
10- Insertion sort
11- Bubble sort
12- merge sort
13- Quick sort
14- Graphs
15- Hash table
16- Binary Heaps
Reference : Object-Oriented Data Structures Using Java - Third Edition by NELL DALE, DANEIEL T.JOYCE and CHIP WEIMS
Slides is owned by College of Computing & Information Technology
King Abdulaziz University, So thanks alot for these great materials
Please write the C++ code that would display the exact same output a.pdfamarndsons
Please write the C++ code that would display the exact same output as provided. Thank you.
main.cpp
#include "TreeNode.h"
//GIVEN
void inorderTraversal(TreeNode * root);
//TODO
TreeNode * search(TreeNode * node,int data);
//GIVEN
void insert(TreeNode * node,int data);
//GIVEN
bool isNull(TreeNode * node){
return node==nullptr;
}
int main() {
// create the root, gets set to null
TreeNode * root;
// create the roor and set the data of root to 5
root= new TreeNode(5);
//create two additional nodes with data values 10 and 3
// these will go to the right and left of root respectively
TreeNode * ten= new TreeNode(10);
TreeNode * three= new TreeNode(3);
//connect ten to the right of root (which has data 5)
root->setRight(ten);
//connect three to the left of root (which has data 5)
root->setLeft(three);
// note this can also be done as
//root.setRight(new TreeNode(10));
//root.setLeft(new TreeNode(3);)
// add two more nodes
//the first has data value 7. So to keep the tree in insorted order, it should get attached as the
left node of ten
// the second has data value 4. So to keep the tree in insorted order, it should get attached as the
right node of three
ten->addLeft(7);
three->addRight(4);
std::cout<<"**************************************\n";
std::cout<<"Printing the Inorder Traversal\n";
inorderTraversal(root);
std::cout<<"**************************************\n";
std::cout<<"Searching for Node \n";
TreeNode* result = search(root,4);
if (result!=nullptr){
std::cout<<"Found "<getData()<<"\n";
}
else
std::cout<<"Not Found "<<4<<"\n";
result = search(root,1);
if (result!=nullptr){
std::cout<<"Found "<getData()<<"\n";
}
else
std::cout<<"Not Found "<<1<<"\n";
std::cout<<"**************************************\n";
std::cout<<"Inserting 6\n";
insert(root,6);
std::cout<<"**************************************\n";
std::cout<<"Printing the Inorder Traversal\n";
inorderTraversal(root);
}
// uses recursion
void inorderTraversal(TreeNode * node){
// exit case
if (isNull(node)) return;
if (node->isLeaf()){
std::cout<<"Printing Leaf Node "<getData()<<"\n";
return;}
// reached a node with no left, so print the node and travel right
if (!isNull(node->getLeft()))
// if there is a left path, then travel further on that
inorderTraversal(node->getLeft());
std::cout<<"Printing Node "<getData()<<"\n";
// save and travel the right path of the current node being processed
inorderTraversal(node->getRight());
}
// uses recursion
//TODO
TreeNode * search(TreeNode * node, int data){
// if the node is null return the null ptr
//if this nodes data equals the search date return found
// if not, if the left tree exists and search data less than
//this nodes data return the result of recursive all to search with left pointer
// if no left tree, but right tree exists and search data greater than
//this nodes data return the result of recursive all to search with right pointer
// if both above conditions not true return null ptr
}
//uses recursion
void insert(TreeNode * node,int .
Given a newly created Binary Search Tree with the following numerica.pdfhadpadrrajeshh
Given a newly created Binary Search Tree with the following numerical key input sequence
(from left to right): 9, 4, 12, 7, 5, 2, 20, 14, 11, 13, 19, 16, 17, 42, 24
a.) We are asked to add a function Position lowestKey(const Position& v) const to the class
SearchTree.
Function prototype: Position lowestKey(const Position& v);
input argument: position of the starting node in the binary search tree to calculate from. For the
whole tree this would be the position for the root of the tree.
return value: position of the node having the lowest key value.
i. Describe strategy with reasonings and examples to convince that it will work.
ii. Implement the function using C++ and show the source code listing.
b) We are also asked to add a function Position highestKey(const Position& v) const to the class
SearchTree.
Function prototype: Position highestKey(const Position& v) const;
input argument: position of the node in the binary search tree to calculate from. For the whole
tree this would be the position for the root of the tree.
return value: position of the node having the highest key value.
i. Describe strategy with reasonings and examples to convince that it will work.
ii. Implement the function using C++ and show the source code listing.
Solution
#include
#include
/* A binary tree node has data, pointer to left child
and a pointer to right child */
struct node
{
int data;
struct node* left;
struct node* right;
};
/* Helper function that allocates a new node
with the given data and NULL left and right
pointers. */
struct node* newNode(int data)
{
struct node* node = (struct node*)
malloc(sizeof(struct node));
node->data = data;
node->left = NULL;
node->right = NULL;
return(node);
}
/* Give a binary search tree and a number,
inserts a new node with the given number in
the correct place in the tree. Returns the new
root pointer which the caller should then use
(the standard trick to avoid using reference
parameters). */
struct node* insert(struct node* node, int data)
{
/* 1. If the tree is empty, return a new,
single node */
if (node == NULL)
return(newNode(data));
else
{
/* 2. Otherwise, recur down the tree */
if (data <= node->data)
node->left = insert(node->left, data);
else
node->right = insert(node->right, data);
/* return the (unchanged) node pointer */
return node;
}
}
/* Given a non-empty binary search tree,
return the minimum data value found in that
tree. Note that the entire tree does not need
to be searched. */
int minValue(struct node* node) {
struct node* current = node;
/* loop down to find the leftmost leaf */
while (current->left != NULL) {
current = current->left;
}
return(current->data);
}
/* Driver program to test sameTree function*/
int main()
{
struct node* root = NULL;
root = insert(root, 4);
insert(root, 2);
insert(root, 1);
insert(root, 3);
insert(root, 6);
insert(root, 5);
printf(\"\ Minimum value in BST is %d\", minValue(root));
getchar();
return 0;
}
#include
#include
/* A binary tree node has data, pointer to left child
.
main.cpp#include TreeNode.h GIVEN void inorderTraversal(.pdfpratikradia365
main.cpp
#include "TreeNode.h"
//GIVEN
void inorderTraversal(TreeNode * root);
//TODO
TreeNode * search(TreeNode * node,int data);
//GIVEN
void insert(TreeNode * node,int data);
//GIVEN
bool isNull(TreeNode * node){
return node==nullptr;
}
int main() {
// create the root, gets set to null
TreeNode * root;
// create the roor and set the data of root to 5
root= new TreeNode(5);
//create two additional nodes with data values 10 and 3
// these will go to the right and left of root respectively
TreeNode * ten= new TreeNode(10);
TreeNode * three= new TreeNode(3);
//connect ten to the right of root (which has data 5)
root->setRight(ten);
//connect three to the left of root (which has data 5)
root->setLeft(three);
// note this can also be done as
//root.setRight(new TreeNode(10));
//root.setLeft(new TreeNode(3);)
// add two more nodes
//the first has data value 7. So to keep the tree in insorted order, it should get attached as the left
node of ten
// the second has data value 4. So to keep the tree in insorted order, it should get attached as the
right node of three
ten->addLeft(7);
three->addRight(4);
std::cout<<"**************************************\n";
std::cout<<"Printing the Inorder Traversal\n";
inorderTraversal(root);
std::cout<<"**************************************\n";
std::cout<<"Searching for Node \n";
TreeNode* result = search(root,4);
if (result!=nullptr){
std::cout<<"Found "<getData()<<"\n";
}
else
std::cout<<"Not Found "<<4<<"\n";
result = search(root,1);
if (result!=nullptr){
std::cout<<"Found "<getData()<<"\n";
}
else
std::cout<<"Not Found "<<1<<"\n";
std::cout<<"**************************************\n";
std::cout<<"Inserting 6\n";
insert(root,6);
std::cout<<"**************************************\n";
std::cout<<"Printing the Inorder Traversal\n";
inorderTraversal(root);
}
// uses recursion
void inorderTraversal(TreeNode * node){
// exit case
if (isNull(node)) return;
if (node->isLeaf()){
std::cout<<"Printing Leaf Node "<getData()<<"\n";
return;}
// reached a node with no left, so print the node and travel right
if (!isNull(node->getLeft()))
// if there is a left path, then travel further on that
inorderTraversal(node->getLeft());
std::cout<<"Printing Node "<getData()<<"\n";
// save and travel the right path of the current node being processed
inorderTraversal(node->getRight());
}
// uses recursion
//TODO
TreeNode * search(TreeNode * node, int data){
// if the node is null return the null ptr
//if this nodes data equals the search date return found
// if not, if the left tree exists and search data less than
//this nodes data return the result of recursive all to search with left pointer
// if no left tree, but right tree exists and search data greater than
//this nodes data return the result of recursive all to search with right pointer
// if both above conditions not true return null ptr
}
//uses recursion
void insert(TreeNode * node,int data){
if (node->getData()==data)
return;
else if(datagetData()){
if (!isNull(node->getLeft.
BSTNode.Java Node class used for implementing the BST. .pdfinfo189835
BSTNode.Java:
/**
* Node class used for implementing the BST.
*
* DO NOT MODIFY THIS FILE!!
*
* @author CS 1332 TAs
* @version 1.0
*/
public class BSTNode> {
private T data;
private BSTNode left;
private BSTNode right;
/**
* Constructs a BSTNode with the given data.
*
* @param data the data stored in the new node
*/
BSTNode(T data) {
this.data = data;
}
/**
* Gets the data.
*
* @return the data
*/
T getData() {
return data;
}
/**
* Gets the left child.
*
* @return the left child
*/
BSTNode getLeft() {
return left;
}
/**
* Gets the right child.
*
* @return the right child
*/
BSTNode getRight() {
return right;
}
/**
* Sets the data.
*
* @param data the new data
*/
void setData(T data) {
this.data = data;
}
/**
* Sets the left child.
*
* @param left the new left child
*/
void setLeft(BSTNode left) {
this.left = left;
}
/**
* Sets the right child.
*
* @param right the new right child
*/
void setRight(BSTNode right) {
this.right = right;
}
}
BST.Java:
import java.util.NoSuchElementException;
/**
* Your implementation of a BST.
*/
public class BST> {
/*
* Do not add new instance variables or modify existing ones.
*/
private BSTNode root;
private int size;
/*
* Do not add a constructor.
*/
/**
* Adds the data to the tree.
*
* This must be done recursively.
*
* The new data should become a leaf in the tree.
*
* Traverse the tree to find the appropriate location. If the data is
* already in the tree, then nothing should be done (the duplicate
* shouldn't get added, and size should not be incremented).
*
* Should be O(log n) for best and average cases and O(n) for worst case.
*
* @param data The data to add to the tree.
* @throws java.lang.IllegalArgumentException If data is null.
*/
public void add(T data) {
// WRITE YOUR CODE HERE (DO NOT MODIFY METHOD HEADER)!
}
/**
* Removes and returns the data from the tree matching the given parameter.
*
* This must be done recursively.
*
* There are 3 cases to consider:
* 1: The node containing the data is a leaf (no children). In this case,
* simply remove it.
* 2: The node containing the data has one child. In this case, simply
* replace it with its child.
* 3: The node containing the data has 2 children. Use the SUCCESSOR to
* replace the data. You should use recursion to find and remove the
* successor (you will likely need an additional helper method to
* handle this case efficiently).
*
* Do NOT return the same data that was passed in. Return the data that
* was stored in the tree.
*
* Hint: Should you use value equality or reference equality?
*
* Must be O(log n) for best and average cases and O(n) for worst case.
*
* @param data The data to remove.
* @return The data that was removed.
* @throws java.lang.IllegalArgumentException If data is null.
* @throws java.util.NoSuchElementException If the data is not in the tree.
*/
public T remove(T data) {
// WRITE YOUR CODE HERE (DO NOT MODIFY METHOD HEADER)!
}
/**
* Returns the root of the tree.
*
* For grading purposes only. You shouldn't need to use this met.
C++ Please write the whole code that is needed for this assignment- wr.docxBrianGHiNewmanv
Brianca plans to save $5,000, $1,000, and $42,000 a year over the next three years, respectively. How much would you need to deposit in one lump sum today to have the same amount as Brianca three years from now if you both earn 10.9 percent, compounded annually? $36,115 $35,192 $43,282 $41,635 $35,372
.
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxmaxinesmith73660
Consider this code using the ArrayBag of Section 5.2 and the Location class from Chapter 2. What is the output?
Location i = new Location(0, 3);
Location j = new Location(0, 3);
b.add(i);
b.add(j);
System.out.println(b.countOccurrences(i));
A. 0
B. 1
C. 2
D. 3
Suppose that b and c are Integer objects. A typical use of the clone method looks like this:
b = (Integer) c.clone( );
Write a short clear explanation of why the (Integer) type cast is required in this typical example.
A. obj = s;
B. s = obj;
C. s = (String) obj;
D. Two or more answers are correct.
Suppose that obj is an Object variable and s is a String variable. Which of the following statements
is a correctly-compiling widening conversion? Don't worry about possible run-time exceptions
A. obj = s;
B. s = obj;
C. s = (String) obj;
D. Two or more answers are correct.
Suppose that x and y are reference variables and a program activates x.equals(y). What occurs if x is the null reference?
A. A NullPointerException occurs
B. It always returns true.
C. It always returns false.
D. It returns true if y is also a null reference; otherwise it returns false.
Consider the implementation of the Stack using a partially-filled array.
What goes wrong if we try to store the top of the Stack at location [0] and the bottom of the Stack at the last used position of the array?
A. Both peek and pop would require linear time.
B. Both push and pop would require linear time.
C. The Stack could not be used to check balanced parentheses.
D. The Stack could not be used to evaluate postfix expressions.
Write some lines of code that declares an Integer object, using the Integer wrapper class.
Assign the value 42 to this object, then copy this value from the Integer object to an ordinary int variable.
Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
What is the maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))?
A. 1
B. 2
C. 3
D. 4
E. 5 or more
Consider the usual algorithm to convert an infix expression to a postfix expression.
Suppose that you have read 10 input characters during a conversion and that the
stack now contains the symbols as shown below. Suppose that you read and process
the 11th symbol of the input. What symbol is at the top of the stack in the case where
the 11th symbol is each of the choices shown?
Which of the following stack operations could result in stack underflow?
Answer
A. is_empty
B. pop
C. push
D. Two or more of the above answers
What is the value of the postfix expression 6 3 2 4 + - *:
Answer
A. Something between -15 and -100
B. Something between -5 and -15
C. Something between 5 and -5
D. Something between 5 and 15
E. Something between 15 and 100
1. An array o.
Page 3
SECTION 1. Algorithm Analysis [1 pt per prompt = 12 points]
TO DO WELL: Before you work on this section, write down
what W(N) means, and the F(N)s of sorting and searching.
1) What is the purpose of using asymptotic notation
such as O, Omega and Theta instead of using
the exact number of comparisons done by a sorting algorithm?
i.e. why do we use O(n^2) instead of saying 2n^2 + 3n + 4
*Because we are only interested in
2) Computing the Average time complexity for a real-world problem is difficult.
Explain why by referring back to the formula for computing A(n).
*Why?
3) Your friend is very excited about having found a sorting algorithm that
sorts in much less than W(n) =Theta(N^2)comparisons even though it corrects
only one bad pair per comparison. He thinks this is the fastest sort ever
and that he will get a Ph.D. tomorrow.
Please teach him why he is wrong.
*Answer:
4) Your friend says she can find a comparison based algorithm that searches
for an element in an ordered list in much less thanW(N) = Theta(log N).
Please teach her why she is wrong.
*Answer:
5) Name2Divide and Conquer algorithms we studied in this class.
*Name:
*Name:
6) Describe 2 Space vs. Time decision cases we discussed in this class.
In what ways can each be called Space vs. Time?
*Example Algorithms: ________ vs.______________
*Reason:
*Example Data Structures: _________vs.____________
*Reason:
7) Name 2 greedy algorithms we have learned in this class.
*Algorithm for solving/finding:
*Algorithm for solving/finding:
SECTION 2. Sorting [2pts per prompt = 10 points]
Your mean employer has five sorting programs. But they are labeled
by their descriptions - no names.
Read each label then say which of the following it is:
Heap Sort
Insertion Sort
Merge Sort
Quick Sort
Radix Sort
1) "I am a good choice if you want consistent theta(nlogn) time and have lots of space."
*Answer: This is
2) "Although I take O(n^2) time in the worst case, on the average
I only use theta(nlogn) and I do not need as much space as another divide and conquer algorithm.”
*Answer: This is
3) "I use theta(nlogn) time in the worst case. The data structure I use is also useful for efficiently implementing priority queues."
*Answer: This is
4) "Even though my average complexity is theta(n^2), I am a good choice if you want to sort small files, or large files that are very nearly in order."
*Answer: This is
5) "I am a good choice if you want to quickly sort a large number of K digit numeric IDs."
*Answer: This is
SECTION 3. Object-Oriented Programming [2pts per prompt = 16 points]
TO DO WELL: Before you work on this section, re-read the notes from Week6 and Week7.
1) (inheritance), we placed data members of the base class in protected.
Why did we do that? Answer each separately.
*Why not private?
*Why not public?
2) You had to overload = to make it work with slists.
.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
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: ________________________