Question 1: Given a binary search tree (BST) and two nodes, find their lowest common ancestor (LCA).
- The root node of the BST. Two nodes for which the LCA is to be found.
- The value of the LCA node.
20
/ \
10 30
/ \ / \
5 15 25 35
Question 2: Given a binary search tree (BST) and a value, insert the value into the BST while maintaining its properties.
- The root node of the BST. The value to be inserted.
- The root node of the updated BST.
BST:
4
/ \
2 7
/ \
1 3
Insert: 5
Updated BST:
4
/ \
2 7
/ \ /
1 3 5
Today, we aim to explore the necessity and function of databases. Given that many of us will be setting up MySQL, we'll focus on foundational questions.
- Create a database named ACM21DOC.
- Create a table named STUDENTS as followed: [ Name VARCHAR(15) NOT NULL, Bdate DATE, Sex CHAR]
- Input some dummy entry and use SELECT * FROM STUDENTS to display all the entry. Submit all the queries performed in a .txt file