0% found this document useful (0 votes)
108 views3 pages

Due After The Quarantine. Stay Safe Everyone.: CMPSC 133: Design & Analysis of Algorithms

This document contains a problem set for a Design and Analysis of Algorithms course. It includes 15 multiple choice questions about B-trees, B+ trees, red-black trees, and AVL trees. It also includes problems describing operations like insertion and deletion in these tree data structures and inserting values into an example AVL tree. The problem set is due after the quarantine period and instructs students to stay safe.

Uploaded by

Flix Load
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views3 pages

Due After The Quarantine. Stay Safe Everyone.: CMPSC 133: Design & Analysis of Algorithms

This document contains a problem set for a Design and Analysis of Algorithms course. It includes 15 multiple choice questions about B-trees, B+ trees, red-black trees, and AVL trees. It also includes problems describing operations like insertion and deletion in these tree data structures and inserting values into an example AVL tree. The problem set is due after the quarantine period and instructs students to stay safe.

Uploaded by

Flix Load
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Republic of the Philippines Name : __________________________

Mariano Marcos State University Course/ Yr/Section : __________________________


College of Arts and Sciences Date : _________________________
DEPARTMENT OF COMPUTER SCIENCE Score : __________________________
Batac 2906 Ilocos Norte
CmpSc 133: Design & Analysis of Algorithms
Problem Set, 2 nd Semester, SY 2019-2020

DUE AFTER THE QUARANTINE. STAY SAFE EVERYONE.


Answer the following problems completely.

I. MULTIPLE CHOICE. Write the letter of the BEST answer before the item number. (2 points each)
1. The minimum number of children of the root node of a B*tree of order m=9.
a. 2 b. 3 c. 4 d. 5
2. The minimum number of key values of an interior node of a B tree of order m=7.
a. 2 b. 3 c. 4 d. 5
3. The maximum number of children in an interior node of a B* tree of order m=5.
a. 3 b. 4 c. 5 d. 6
4. In a B+ tree, S0 is a pointer to a node containing key values ____ the first key value in the parent node.
a. > b. < c. ≤ d. ≥
5. In a B tree, Sn is a pointer to a node containing key values ____ the last key value in the parent node.
a. > b. < c. ≤ d. ≥
6. A kind of tree which is useful in storing words in a dictionary.
a. B tree b. B* tree c. B+ tree d. Trie
7. Insertion in a full root node of a B* tree, where all the children are also full results to a/an
a. increase in tree height b. merge c. rotation d. redistribution
8. Deletion in an interior node of a B tree where the children contain the minimum number of key
values results to a
a. split b. merge c. rotation d. redistribution
9. Deletion in the root node of a B * tree with only one key value and the children are all at a minimum
results to a
a. split b. merge c. rotation d. decrease in tree height
10. Insertion to a full node in a B tree results to a
a. split b. merge c. rotation d. redistribution
11. The minimum number of key values in the interior node of a B* tree of order m is
a. m/2 b. (m/2) -1 c. (2m-1)/3 d. (2m-1)/3 - 1
12. The color of the root node of a red-black tree is
a. always red b. always black c. maybe red or black d. does not matter
13. The children of a red node in a red-black tree is
a. always red b. always black c. maybe red or black d. does not matter
14. A node in a B tree with 3 key values can have 0 or
m. 2 pointers a. 3 pointers t. 4 pointers h. 1,2,3, or 4 pointers
15. In an AVL tree, the height difference between the left and the right subtree is
w. at most 1 r. at least 1 u. exactly 1 k. exactly 0

II. Describe briefly each of the following operations: (note that the involved node may either contain the
minimum number of key values, more than the minimum, or full)
1. Insertion in the root node of a B tree ; (10 points)
a) root node is full
The next key value to be inserted at the root node that is full will cause the root node to split into 2
nodes

b) root node is at a minimum


value will be inserted at right of the current value of the root node when value < than the
current value of the root or value will be inserted at left of the current value of the root node when
value > than the current value of the root node

Prepared by: AENCGarcia/////2020//


2. Deletion in a leaf node of a B* tree (10 points)
a) the leaf node is at a minimum
Target node can borrow key from immediate left node, or immediate right
node (sibling) if they have more than minimum number of keys. If this case is
true, The key will be borrowed from the parent node, the max value will be
transferred to a parent, the max value of the parent node will be transferred to
the target node, and remove the target value.

If no siblings have more than minimum number of keys, Merge with siblings and the
minimum of parent nodes

Total keys will be now more than min

The target key will be replaced with the minimum of a parent node

b) the leaf node contains more than the minimum


target value in the leaf node will just be deleted then the deletion is finished.

3. Insertion in an AVL tree (10 points)


insertion in an avl must always satisfy the concept that the value of the right child is > key value in
parent, and the key value in the left child is < key value in the parent. Since AVL tree is a self-balancing
tree, it can have RR, RL, LL, LR rotation after insertion.

4. Insertion in a red-black tree. (10 points)

The algorithm has three steps:

1. Insert as you would into a BST, coloring the node red.


2. If the parent of the node you just inserted was red, you have a double-red problem which you
must correct.
3. Color the root node black.

Prepared by: AENCGarcia/////2020//


A double red problem is corrected with zero or more recolorings followed by zero or one
restructuring.

III. Insert the following key values into an AVL tree. Rotate as necessary and identify the kind of rotation
applied in each case: (10 points)
10, 20, 30, 40, 50, 05, 01, 65, 55.

Prepared by: AENCGarcia/////2020//

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy