Short answer Another approach to the update algorithm is to perform use the delete function for the old value and if it is successful, call the insert function using the new value. Explain in your own words if you think this approach is significantly better, worse, or in the same category as the algorithm discussed in the slides, and why. I attached the pictures of the algorithm discussed in the slides.
Short answer Another approach to the update algorithm is to perform use the delete function for the old value and if it is successful, call the insert function using the new value. Explain in your own words if you think this approach is significantly better, worse, or in the same category as the algorithm discussed in the slides, and why. I attached the pictures of the algorithm discussed in the slides.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Short answer
Another approach to the update
I attached the pictures of the algorithm discussed in the slides.
![Sorted Arrays
Code for update (uses binary search function):
else
// newValue is to the right
{
if (recordIndex == 0)
return true;
nextIndex = recordIndex - 1;
while (nextIndex >= 0 && newValue < numbers [nextIndex])
{
numbers [nextIndex+1] = numbers [nextIndex];
nextIndex--;
}
nextIndex++;
numbers [nextIndex] = newValue;
return true;
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5cc38ce6-b814-49a7-adf4-92412b56b3a8%2F7ba6cc53-2cbb-4ea3-a5e3-eea9b6cfa5e8%2F99ljvi_processed.png&w=3840&q=75)
Transcribed Image Text:Sorted Arrays
Code for update (uses binary search function):
else
// newValue is to the right
{
if (recordIndex == 0)
return true;
nextIndex = recordIndex - 1;
while (nextIndex >= 0 && newValue < numbers [nextIndex])
{
numbers [nextIndex+1] = numbers [nextIndex];
nextIndex--;
}
nextIndex++;
numbers [nextIndex] = newValue;
return true;
}
![Sorted Arrays
Code for update (uses binary search function):
boolean updateBinarySearchMoveAndShift (int oldvalue, int newValue)
{
int recordIndex
binarySearch (oldvalue);
if (recordIndex
-1)
==
return false;
int nextIndex = 0;
if (newValue > oldvalue) // newValue is to the left
{
nextIndex = recordIndex + 1;
if (nextIndex == currentSize)
return true;
while (nextIndex < currentSize &6 newValue > numbers [nextIndex])
{
numbers [nextIndex-1] = numbers [nextIndex];
nextIndex++;
}
nextIndex--;
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5cc38ce6-b814-49a7-adf4-92412b56b3a8%2F7ba6cc53-2cbb-4ea3-a5e3-eea9b6cfa5e8%2F8iev6r9_processed.png&w=3840&q=75)
Transcribed Image Text:Sorted Arrays
Code for update (uses binary search function):
boolean updateBinarySearchMoveAndShift (int oldvalue, int newValue)
{
int recordIndex
binarySearch (oldvalue);
if (recordIndex
-1)
==
return false;
int nextIndex = 0;
if (newValue > oldvalue) // newValue is to the left
{
nextIndex = recordIndex + 1;
if (nextIndex == currentSize)
return true;
while (nextIndex < currentSize &6 newValue > numbers [nextIndex])
{
numbers [nextIndex-1] = numbers [nextIndex];
nextIndex++;
}
nextIndex--;
}
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images

Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education