Review Test Submission: Examination
Opportunity 2
Course COS 212 S1 2020
Test Examination Opportunity 2
Started 6/11/20 5:30 PM
Submitted 6/11/20 7:30 PM
Due Date 6/11/20 7:40 PM
Status Completed
Attempt 20.41666 out of 40 points
Score
Time 2 hours, 0 minute out of 2 hours
Elapsed
Instruction The University of Pretoria commits itself to produce academic
s
work of integrity. I affirm that I am aware of and have read the
Rules and Policies of the University, more specifically the
Disciplinary Procedure and the Tests and Examinations Rules,
which prohibit any unethical, dishonest or improper conduct
during tests, assignments, examinations and/or any other
forms of assessment. I am aware that no student or any other
person may assist or attempt to assist another student, or
obtain help, or attempt to obtain help from another student or
any other person during tests, assessments, assignments,
examinations and/or any other forms of assessment.
Results Submitted Answers, Feedback, Incorrectly Answered Questions
Displayed
Question 1
2 out of 2 points
Consider the B-tree in Figure 1:
Assume value 55 is inserted into the B-tree shown on Figure 1. Since insertion in B-
trees always happens at leaf level, 55 will be inserted into some leaf node. What
values will the parent of this leaf node contain after the insertion has taken place?
Selected f.
Answer: [26, 45]
Question 2
2 out of 2 points
, Consider the B-tree in Figure 1:
Assume value 55 is inserted into the B-tree shown in Figure 1. What values will the
root node contain after the insertion has taken place?
Selected f.
Answer: [60]
Question 3
0 out of 4 points
Consider the following BTreeNode and BTree classes:
public class BTreeNode {
int maxKeys; // Maximum number of keys that can be stored
int numberOfKeys; // Number of keys currently stored
Integer[] keys; // Integer key values
BTreeNode[] children; // Pointers to children (children are all null
in leaves)
// Create a BTreeNode that can store n keys
BTreeNode(int n) { ... }
// Find value, starting the search from this node
// If value found in the node, return pointer to child node
to the left of value
// Otherwise, return null
BTreeNode findLeftChild(Integer value) { ... }
// If value is contained in non-leaf node, return immediate
predecessor
// Otherwise, return null
Integer immediatePredecessor(Integer value) {
// provide your implementation here
}
}
public class BTree {
BTreeNode root;
int maxKeys;
// Create a BTree that can store n keys
BTree(int n) { ... }
// Insert value into this BTree
void insertInteger(Integer value) { ... }
// Delete value from this BTree
void deleteInteger(Integer value) { ... }
}
Complete the provided immediatePredecessor method. You may assume that
all the other provided methods in the BTreeNode and BTree classes are
Opportunity 2
Course COS 212 S1 2020
Test Examination Opportunity 2
Started 6/11/20 5:30 PM
Submitted 6/11/20 7:30 PM
Due Date 6/11/20 7:40 PM
Status Completed
Attempt 20.41666 out of 40 points
Score
Time 2 hours, 0 minute out of 2 hours
Elapsed
Instruction The University of Pretoria commits itself to produce academic
s
work of integrity. I affirm that I am aware of and have read the
Rules and Policies of the University, more specifically the
Disciplinary Procedure and the Tests and Examinations Rules,
which prohibit any unethical, dishonest or improper conduct
during tests, assignments, examinations and/or any other
forms of assessment. I am aware that no student or any other
person may assist or attempt to assist another student, or
obtain help, or attempt to obtain help from another student or
any other person during tests, assessments, assignments,
examinations and/or any other forms of assessment.
Results Submitted Answers, Feedback, Incorrectly Answered Questions
Displayed
Question 1
2 out of 2 points
Consider the B-tree in Figure 1:
Assume value 55 is inserted into the B-tree shown on Figure 1. Since insertion in B-
trees always happens at leaf level, 55 will be inserted into some leaf node. What
values will the parent of this leaf node contain after the insertion has taken place?
Selected f.
Answer: [26, 45]
Question 2
2 out of 2 points
, Consider the B-tree in Figure 1:
Assume value 55 is inserted into the B-tree shown in Figure 1. What values will the
root node contain after the insertion has taken place?
Selected f.
Answer: [60]
Question 3
0 out of 4 points
Consider the following BTreeNode and BTree classes:
public class BTreeNode {
int maxKeys; // Maximum number of keys that can be stored
int numberOfKeys; // Number of keys currently stored
Integer[] keys; // Integer key values
BTreeNode[] children; // Pointers to children (children are all null
in leaves)
// Create a BTreeNode that can store n keys
BTreeNode(int n) { ... }
// Find value, starting the search from this node
// If value found in the node, return pointer to child node
to the left of value
// Otherwise, return null
BTreeNode findLeftChild(Integer value) { ... }
// If value is contained in non-leaf node, return immediate
predecessor
// Otherwise, return null
Integer immediatePredecessor(Integer value) {
// provide your implementation here
}
}
public class BTree {
BTreeNode root;
int maxKeys;
// Create a BTree that can store n keys
BTree(int n) { ... }
// Insert value into this BTree
void insertInteger(Integer value) { ... }
// Delete value from this BTree
void deleteInteger(Integer value) { ... }
}
Complete the provided immediatePredecessor method. You may assume that
all the other provided methods in the BTreeNode and BTree classes are