Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a python program for this question. Your task is to compute the number of disk accesses for searching on a B-tree thru experiments with
Write a python program for this question.
Your task is to compute the number of disk accesses for searching on a B-tree thru experiments with the following assumptions: 1. Keys are positive integers. 2. A page can hold 1K keys (with default size for integers), where K=1,024, and the associated data, with the minimum degree t=512. 3. Available RAM for storing B-tree nodes: 64K nodes, where each node is a page (a node may not be full, but that still takes a page). 4. Ignore how a page is addressed on disk. In other words, you may simply assume that retrieving one page takes 1 DISK-READ which is 1 disk access (with associated data), and storing one page to disk takes 1 DISK-WRITE, which is 1 disk acess. Moreover, each disk-read only reads one page and each disk-write only writes one page. 5. Disk storage is sufficiently large that can hold 100K keys and the data associated with them (which pages contain which keys depend on the construction of the B-tree). 6. The root note is in RAM. n each round of experiment, use a random permutation to permute 1,2,,100,000 to be used as keys. Construct a B-tree for these keys in the permuted order and store the tree on the disk imaginary). At the beginning, only the root node of the B-tree is in RAM. Then generate a randome sequence of 100 numbers using a pseudo-random number generator between the range of and 100,000 , which is the sequence of keys to search for data. Count the number of disk accesses that actually happens for this search sequence. For example, suppose a key k is at level 2 n the tree, where the root is at the level 0 , then you will first need to read in the parent node of the node that contains k by checking with the root node, from the parent node, you read in the node (page) that contains k and get the data associated with k. This incurs 2 DISK-READ. When the allocated space of 64K in RAM is full, you will need to release one page back to the disk, irst in first out. For simplicity, assume that when you release a page you need to write this page back to disk since the data associated with a key may be changed, which incurs 1 disk access. f the node containing key k is already in RAM, then there is no need of disk access. Run the experiment for 10 rounds, compute the minimum, maximum, and the average numbers of disk accesses. What conclusions can you draw? Note: To generate a random permulation to permute 1,2,,100,000, you may use import numpy as np rey_list =[k+1 for k in np.random. permutation (100_000)]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started