Determine if the following statement are true or false screen shot shows the text's SortedArrayCollection and ArrayCollection When comparing two objects using the == operator, what is actually compared is the references to the objects. When comparing two objects using the equals method inherited from the Object class, what is actually compared is the references to the objects.

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
icon
Related questions
Question

Determine if the following statement are true or false

screen shot shows the text's SortedArrayCollection and ArrayCollection

When comparing two objects using the == operator, what is actually compared is the references to the objects.

When comparing two objects using the equals method inherited from the Object class, what is actually compared is the references to the objects.

The text's sorted array-based collection implementation stores elements in the lowest possible indices of the array.

The text's array-based collection implementation stores elements in the lowest possible indices of the array.

 

return found;
}
public class Arraysellectien<T> implements Çollectionlatertace<T>
protected final int DEFCAP = 100; // default capacity
protected T] elements;
protected int numElements = Q;// number of elements in this collection
// array to hold collectionas elements
public boolean contains (T target)
// Returns true if this collection contains an element e such that
// set by find method
protected boolean found: // true if target found, otherwise false
protected int location: // indicates location of target if found
// eeguals(target); otherwise, returns false.
{
find(target);
return found3;
public ArraySelectien()
{
elements = (T[]) new Object[DEFCAP];
public T get(T target)
// Returns an element e from this collection such that e.eguals(target);
// if no such element exists, returns null.
}
{
public ArrayCelectienlint capacity)
{
elements = (T) new Object[capacity];
}
find(target);
if (found)
return elements[location];
else
return null;
protected void find(T target)
// Searches elements for an occurrence of an element e such that
// eeguals(target). If successful, sets instance variables
// found to true and location to the array index of e. If
// not successful, sets found to false.
{
int location = 0;
found = false;
}
public boolean isEullO
// Returns true if this collection is full; otherwise, returns false.
{
return (nwmElements == slementslensth);
}
public boglean isEmrtx0
// Returns true if this collection is empty; otherwise, returns false.
while (location < nwmElements)
{
if (elements[location] eguals(target))
{
found = true;
{
return (nymElements == 0);
}
public int sizel)
// Returns the number of elements in this collection.
return;
}
{
return nymElenments;
}
else
location++;
}
}
}
public boglean add(T element)
// Attempts to add element to this collection.
// Returns true if successful, false otherwise.
{
if (isEullO)
return false;
else
{
elements[nwmElements) =
DwmElements++;
= element;
return true;
}
}
public boglean remove (T target)
// Removes an element e from this collection such that eeguals(target)
// and returns true; if no such element exists, returns false.
{
find(target);
if (found)
{
elements[location] = elementsinwmElements- 1);
elementslowmElements - 1] = null;
DWMElements-
}
Transcribed Image Text:return found; } public class Arraysellectien<T> implements Çollectionlatertace<T> protected final int DEFCAP = 100; // default capacity protected T] elements; protected int numElements = Q;// number of elements in this collection // array to hold collectionas elements public boolean contains (T target) // Returns true if this collection contains an element e such that // set by find method protected boolean found: // true if target found, otherwise false protected int location: // indicates location of target if found // eeguals(target); otherwise, returns false. { find(target); return found3; public ArraySelectien() { elements = (T[]) new Object[DEFCAP]; public T get(T target) // Returns an element e from this collection such that e.eguals(target); // if no such element exists, returns null. } { public ArrayCelectienlint capacity) { elements = (T) new Object[capacity]; } find(target); if (found) return elements[location]; else return null; protected void find(T target) // Searches elements for an occurrence of an element e such that // eeguals(target). If successful, sets instance variables // found to true and location to the array index of e. If // not successful, sets found to false. { int location = 0; found = false; } public boolean isEullO // Returns true if this collection is full; otherwise, returns false. { return (nwmElements == slementslensth); } public boglean isEmrtx0 // Returns true if this collection is empty; otherwise, returns false. while (location < nwmElements) { if (elements[location] eguals(target)) { found = true; { return (nymElements == 0); } public int sizel) // Returns the number of elements in this collection. return; } { return nymElenments; } else location++; } } } public boglean add(T element) // Attempts to add element to this collection. // Returns true if successful, false otherwise. { if (isEullO) return false; else { elements[nwmElements) = DwmElements++; = element; return true; } } public boglean remove (T target) // Removes an element e from this collection such that eeguals(target) // and returns true; if no such element exists, returns false. { find(target); if (found) { elements[location] = elementsinwmElements- 1); elementslowmElements - 1] = null; DWMElements- }
public class SortedArraxCollection<T> implements CollectionInterface<T> {
public boolean add(T element)
// Precondition: element is Comparable to previously added objects
//
protected final int DEFCAP = 100; // default capacity
protected int origCan; // original capacity
protected TI elements; // array to hold collection elements
protected int nymĒlements = 0; // number of elements in this collection
// Adds element to this collection.
{
if (nwmElements =slements.Jength)
enlarge();
// set by find method
protected boolean found; // true if target found, otherwise false
protected int location; // indicates location of target if found,
find(element); // sets location to index where element belongs
þublic SortedAraxCollection() {
for (int index = pwmElements: index > location; index--)
elements[index] = elements[index - l];
elements = (TLI) new Object[DEFCAP];
origCan = DEFCAP;
%3D
%3D
elements[location] = element;
nwmElements++;
return true;
}
public SottedAraxCollection(int capacity) {
elements = (TE) new Object[capacity];
this.origCan = capacity;
}
}
public boolean temaxe(T target)
// Removes an element e from this collection such that e.eguals(target)
// and returns true; if no such element exists, returns false.
{
protected void enlarge)
// Increments the capacity of the collection by an amount
// equal to the original capacity.
{
find(target);
if (found) {
// Create the larger array.
TII larger = (T[]) new Object[elemEntsJength+ origarl;
for (int i= location; i<= nwmElements - 2; i++)
elements[i] = elementsli + 1];
elementslowmElements - 1] = null;
numElements-;
// Copy the contents from the smaller array into the larger array.
for (int i = 0; i< nwmElements: it+) {
}
return found;
larger[i] = elements[i];
}
}
// Reassign elements reference.
elements = larger;
public int size)
// Returns the number of elements on this collection.
{
%3D
}
return numElements:
protected void find(T target)
// Searches elements for an occurrence of an element e such that
// e.eguals(target). If successful, sets instance variables
// found to true and location to the array index of e. If
// not successful, sets found to false and location to the
//
}
public boolsan contains(T target)
// Returns true if this collection contains an element e such that
// Eeauals(target); otherwise, returns false.
{
array
index where target should be inserted.
find(target);
return found;
{
location = 0;
found = false;
if (LisEmpty())
}
reckind(target, 0, nwmElements - 1);
public T get(T target)
// Returns an element e from this collection such that eeguals(target);
// if no such element exists, returns null.
{
}
protected void recEind(T target, int first, int last)
// Used by find.
{
find(target);
if (found)
int result; // result of the comparison
if (first > last) {
return elements[location];
else
found = false;
return null;
result = ((Comparable) target),compars:Tolelements[location]);
if (result > 0)
}
%3D
location++; // adjust location to indicate insert index
public boolean isEmpty()
// Returns true if this collection is empty; otherwise, returns false.
{
} else {
location = (first + last) / 2;
result = ((Comparable) target).compareTolelements[location]);
if (result
return (numElements == 0);
0) // found target
found = true;
}
else if (result > 0) // target too high
public boolean isEullO)
// This collection is unbounded so always returns false.
{
veckind(target, location + 1, last);
else // target too low
reckind(target, first, location - 1);
return false;
}
}
Transcribed Image Text:public class SortedArraxCollection<T> implements CollectionInterface<T> { public boolean add(T element) // Precondition: element is Comparable to previously added objects // protected final int DEFCAP = 100; // default capacity protected int origCan; // original capacity protected TI elements; // array to hold collection elements protected int nymĒlements = 0; // number of elements in this collection // Adds element to this collection. { if (nwmElements =slements.Jength) enlarge(); // set by find method protected boolean found; // true if target found, otherwise false protected int location; // indicates location of target if found, find(element); // sets location to index where element belongs þublic SortedAraxCollection() { for (int index = pwmElements: index > location; index--) elements[index] = elements[index - l]; elements = (TLI) new Object[DEFCAP]; origCan = DEFCAP; %3D %3D elements[location] = element; nwmElements++; return true; } public SottedAraxCollection(int capacity) { elements = (TE) new Object[capacity]; this.origCan = capacity; } } public boolean temaxe(T target) // Removes an element e from this collection such that e.eguals(target) // and returns true; if no such element exists, returns false. { protected void enlarge) // Increments the capacity of the collection by an amount // equal to the original capacity. { find(target); if (found) { // Create the larger array. TII larger = (T[]) new Object[elemEntsJength+ origarl; for (int i= location; i<= nwmElements - 2; i++) elements[i] = elementsli + 1]; elementslowmElements - 1] = null; numElements-; // Copy the contents from the smaller array into the larger array. for (int i = 0; i< nwmElements: it+) { } return found; larger[i] = elements[i]; } } // Reassign elements reference. elements = larger; public int size) // Returns the number of elements on this collection. { %3D } return numElements: protected void find(T target) // Searches elements for an occurrence of an element e such that // e.eguals(target). If successful, sets instance variables // found to true and location to the array index of e. If // not successful, sets found to false and location to the // } public boolsan contains(T target) // Returns true if this collection contains an element e such that // Eeauals(target); otherwise, returns false. { array index where target should be inserted. find(target); return found; { location = 0; found = false; if (LisEmpty()) } reckind(target, 0, nwmElements - 1); public T get(T target) // Returns an element e from this collection such that eeguals(target); // if no such element exists, returns null. { } protected void recEind(T target, int first, int last) // Used by find. { find(target); if (found) int result; // result of the comparison if (first > last) { return elements[location]; else found = false; return null; result = ((Comparable) target),compars:Tolelements[location]); if (result > 0) } %3D location++; // adjust location to indicate insert index public boolean isEmpty() // Returns true if this collection is empty; otherwise, returns false. { } else { location = (first + last) / 2; result = ((Comparable) target).compareTolelements[location]); if (result return (numElements == 0); 0) // found target found = true; } else if (result > 0) // target too high public boolean isEullO) // This collection is unbounded so always returns false. { veckind(target, location + 1, last); else // target too low reckind(target, first, location - 1); return false; } }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education