What is benefit of using a key-indexed array implementation

Assignment Help Data Structure & Algorithms
Reference no: EM131070360

Algorithm Design and Analysis

Directions: Please complete each of the following exercises. Please read the instructions carefully.

For all "short programming assignments," include source code files in your submission.

1. The following refer to symbol table implementations.

a. What is the benefit of using a key-indexed array implementation?
b. Give a circumstance under which a key-indexed array implementation is inappropriate.

2. Short programming assignment. Implement the array-based symbol table from program 12.5, adding a remove operation.

3. In the following sorted file we are searching for J. Show the values that would be checked at each step for both a binary search and an interpolation search. Show all calculations.

A A B E F H J M N N N N O P P P P P R R R R T T T Z Z Z Z Z Z Z

4. The following refer to binary search trees.

a. Draw the binary search tree that results when the keys I N S E R T M D (in that order) are inserted into an initially empty tree.
b. Explain why searching and insertion may still require N operations in the worst case for binary search trees.

5. The following refer to indexed implementations of symbols tables.

a. What is the advantage of an indexed implementation when table items are large?
b. When is an indexed implementation inappropriate?

6. Using the algorithm represented in Programs 12.13 and 12.12, show the BST that results from inserting D into the following:

7. The following refer to methods of providing guaranteed performance for search trees.

a. Explain how the algorithm in Program 13.1 results in a balanced tree.
b. Explain the difference between randomized, amortized, and optimized approaches to gauranteed performance.
c. Why does a randomized BST require that each node store the count of nodes in the subtree?

8. The following refer to splay BSTs.

a. What is the difference between a splay BST and an ordinary BST?
b. Draw the splay BST that results when you insert the items I N S E R T M D into an initially empty tree.

9. Convert the following 2-3-4 tree into a red-black tree:

10. The following refer to skip lists.

a. Explain the trade-offs resulting from increasing and decreasing the parameter t.
b. Draw the skip list that results from inserting the keys I N S E R T M into an initially empty list, assuming that randX returns the sequence 1 1 2 1 3 2 3.

 

Program 12.12 Rotations in BST's

These twin routines perform the rotation operation on a BST. A right rotation makes the old root the right subtree of the new root (the old left subtree of the root); a left rotation makes the old root the left subtree of the new root (the old right subtree of the root). For implementations where a count field is maintained in the nodes (for example, to support select, as we will see in Section 14.9), we need also to exchange the count fields in the nodes involved in the rotation.

void rotR(link& h)

{ link x = h->1; h->1 = x->r; x->r = h; h = x; }

void rotL(link& h)

{ link x = h->r; h->r = x->1; x->1 = h; h = x; }

Program 12.13 Root insertion in BSTs

With the rotation functions in Program i z. z 2, a recursive function that inserts a new node at the root of a BST is immediate: Insert the new item at the root in the appropriate subtree, then perform the appropriate rotation to bring it to the root of the main tree.

private:

void insertT(link& h, Item x)

{ if (h == 0) { h = new node(x); return;

if (x.key() < h->item.key())

{ insertT(h->l, x); rotR(h); }

else { insertT(h->r, x); rotL(h); }

}

public:

void insert(Item item)

{ insertT(head, item); }

Reference no: EM131070360

Questions Cloud

Difference between cultural assimilation and appreciation : What is the difference between cultural assimilation and appreciation
Cultural appropriation and cultural appreciation : What is the difference between cultural appropriation and cultural appreciation
Magnitude of the centripetal acceleration : What is the magnitude of the linear velocity v for points at the edge of the disk? What is the period T of the rotations? What is the magnitude of the centripetal acceleration?
What is the total distance the runner covered : One runnercompletes 10 laps of the race. What is the total distance the runner covered? What is the total displacement for the runner?
What is benefit of using a key-indexed array implementation : What is the benefit of using a key-indexed array implementation? Give a circumstance under which a key-indexed array implementation is inappropriate.
What percent have homozygous recessive genotypes : If we observe/survey our campus population and we observe that 75% of our subjects are right handed. What percent have homozygous recessive genotypes in our population
Determining the resistance of the resistor : What was the effect of reducing the resistance of the resistor on the way the capacitor discharged?
Recording of the electrical activity of the heart : 1. Electrocardiogram (ECG) is a recording of the electrical activity of the heart which is clinically utilized to monitor patients and diagnosis life threatening cardiac arrhythmias [1]. See Figure 1. Remote monitoring in a patient'shome or office..
What environmental factors may have helped : Speculate on what environmental factors may have helped bring about this change and explain how. Be creative, but use scientific explanations to explain the process

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Create a report based on the query

Increase the font size of the Total Purchases by Customer label (in the strCustomerNameFooter section) to 11 and the =Sum calculated control to 10 points. Change the font color of both to dark blue.

  Define the data structure array

Define the data structure array. Include uses; what represent the name of the array; importance of the index value; naming of the variables bundle within the array.

  Why is understanding algorithm efficiency so critical

Why is understanding Algorithm Efficiency so critical?

  Algorithm for string of numbers recognize all the substrings

Write down algorithm, using pseudocode, to perform the following task, Given a string of numbers, recognize all of the substrings that form numbers that are divisible by 3.

  Compute a shortest-path

Compute a shortest-path from u to v (instead of from u to all the nodes). One way to speed up Dijkstra's algorithm might be to run the algorithm u and from v at the same time.

  They have collected by interviewing members of a village.

An efficient algorithm is proposed to do this: either it produces proposed dates of birth and death for each of the n people so that all the facts hold true, or it reports (correctly) that no such dates can exist. That is the facts collected by th..

  Explain binary tree by induction

Binary tree is full if all of its vertices have either zero or two children. Let Bn denote number of full binary trees with n vertices. Illustrate by induction (substitution) that Bn is 2 (n) .

  Write a program flowchart

Write a program FLOWCHART that lets the user enter a sequence of numbers. The program should stop when it notices that the last two numbers entered were identical.

  Discuss how concurrency control mechanism interacts

Describe, with examples, the types of problem that can occur in a multi-user environment when concurrent access to the database is allowed. Give full details of a mechanism for concurrency control that can be used to ensure that the types of probl..

  Write a script that checks the day of the week

Write a script that checks the day of the week, and takes one of two actions depending on the day. If the day is Monday through Friday, print the name of the day.

  Algorithm to compute-report grade-point average for class

Compute and report grade-point average for class. Determine the sum of the grades; count number of students; compute average. Determine its algorithm?

  Question about pointerlists

Whenever the pointer of a list or a tree is manipulated, procedure that performs this operation must be considered to be in a critical section.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd