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

  Which business functions be impacted by your action plan

Identify leadership strategies you plan to implement throughout the execution of your action plan. In particular, explain which strategies you would implement to foster team collaboration among the multiple stakeholders who must collaborate to suc..

  Arraysq1-write a program to find average marks obtained by

arraysq1-write a program to find average marks obtained by 10 students in a test along with algorithm?q2 -write a menu

  You have been commissioned to prepare a manual covering the

in a 6-8-page paper complete the followingyou have been commissioned to create a manual covering the installation

  Describe a method for over tting-avoidance

Which would be chosen as the \best" attribute by a decision tree learner using the information gain splitting criterion and describe a method for over tting-avoidance in decision tree learning.

  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.

  Write at least a one-page critic of the cisc approach

write at least a one-page critic of the CISC approach showing its disadvantages while showing the advantages of the RISC approach. You may want to use real-life example machine performance as a support for your support of the RISC philosophy.

  Write a flowchart to solve any linear equation ax+b=01.

Write a flowchart to solve any linear equation ax+b=01. W Write a flowchart to solve any linear equation ax^2+bx+C=0

  Operation when you use the quick union algorithm

Show the contents of the id array after each union operation when you use the quick union algorithm (Program below) to solve the connectivity problem for the sequence 0-2, 1-4, 2-5, 3-6, 0-4, 6-0, and 1-3.

  Exhibit an algorithm that detects automation

Exhibit an algorithm that detects whether one finite automaton accepts a subset of the set accepted by another machine.

  Explaining playout delay algorithm

Let the adaptive playout delay algorithm. Show through simple example that adjusting playout delay at beginning of each talk.

  Consider that the size of the hash tab is m=16. apply linear

Consider that the size of the hastable is M=16. Apply linear probing with f(i)=i for the following keys. Convert each of the keys to a number associated with the sequence of English alphabet and then draw a table that indicates successful and unsucce..

  Replace the letter n with the letter g and alter the pointer

Then how do I replace the letter N with the letter G and alter the pointers so that the new letter appears in the list in its proper place in alphabetical order?

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