Question

True or False? 1. If a sorted list is empty, a call to the getNodeBefore method...

True or False?

1. If a sorted list is empty, a call to the getNodeBefore method returns null.

2. In the SortedList implementation, the add method sets the sign of the integer it returns to indicate whether the entry exists in the list already.

3. If a class inherits a method that is inappropriate, you can override it with a method that throws an exception when called.

4. You cannot use inheritance and maintain efficiency of a base class if protected access is used to grant access to the underlying data structure.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution

1)True

2)True

3)True

4)True

Explanation

1)

If it contains nullptr, the original sorted list is empty, so the getNodeBefore returns nullptr

Hence Answer is True

---

2)

In the SortedList implementation, the add method sets the sign of the integer it returns to indicate whether the entry exists in the list already.

Hence Answer is True

--

3)

If a class inherits a method that is inappropriate, you can override it with a method that throws an exception when called.

for e.g

throw new UnsupportedOperationException();

Hence Answer is True

---

4)

protectedaccess modifier that allows subclasses to access the data

But  we cannot maintain efficiency of a base class if protected access is used to grant access to the underlying data structure.

Hence Answer is True

---

all the best

Add a comment
Know the answer?
Add Answer to:
True or False? 1. If a sorted list is empty, a call to the getNodeBefore method...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Create a class that implements a sorted, doubly-linked list: Start with a copy of the...

    C++ Create a class that implements a sorted, doubly-linked list: Start with a copy of the sortedList class. Call your new class doublyLinkedList. Convert the baseline code into a doubly linkedlist, and thoroughly test all existing operations (make sure to check all edge conditions), and then implement the new operations below. The class should have the following additional class methods: • A reverse method: this method will reverse the order of the doubly linked list. This method takes no parameters,...

  • Write a JAVA contains method for a linked implementation of a sorted list. #This method is...

    Write a JAVA contains method for a linked implementation of a sorted list. #This method is written from the implementation perspective, meaning it would go inside of the LinkedSortedList class. This means we have access to firstNode and numberOfEntries. #write an efficient solution. This will involve directly accessing the linked structure rather than only invoking existing methods. You can assume T is Comparable. #The method header is: public boolean contains(T anEntry)

  • Are based on the following Queue class code segment class QueueFull {/* Empty exception class */};...

    Are based on the following Queue class code segment class QueueFull {/* Empty exception class */}; Class Queue Empty {/* Empty exception class */}; struct Node//Node structure int data;//Holds an integer Node* next;//Pointer to next node in the queue}; Class Queue//Linked node implementation of Queue ADT {Private: Node* front;//Pointer to front node of queue Node* rear;//pointer to last node of queue Public: Queue ()://default constructor initializes queue to be empty -Queue ();//Deallocates all nodes in the queue Void Add (int...

  • Using a doubly linked list as the underlying data structure, implement a list ADT that implements...

    Using a doubly linked list as the underlying data structure, implement a list ADT that implements the ListInterface.java found in the ProgProjTwo Eclipse project starting point for this assignment. In addition to the forward iterator defined by resetIterator( ) and getNextItem( ) in ListInterface.java, implement a backwards iterator by providing resetBackIterator( ) and getPreviousItem( ) methods. As noted in the syllabus addendum, you are encouraged to develop a find( ) helper method that can support various list ADT operations. A...

  • Implement a method to build an AVL tree out of a sorted (ascending order) array of...

    Implement a method to build an AVL tree out of a sorted (ascending order) array of unique integers, with the fastest possible big O running time. You may implement private helper methods as necessary. If your code builds a tree that is other than an AVL tree, you will not get any credit. If your code builds an AVL tree, but is not the fastest big O implementation, you will get at most 12 points. You may use any of...

  • True or False: 1. Much like a list, a set contains items that are in a...

    True or False: 1. Much like a list, a set contains items that are in a particular order. ANSWER 2. With a set, the difference and subset operations are not symmetric. ANSWER 3. The submethod of the set class returns a set containing items in s1 that are not in s2. ANSWER: 4. If SI and s2 are sets, the expression s1.issubset(s2) returns True if s2 is a subset of s1. ANSWER 5.A set is similar to a bag, but...

  • I need help with the Implementation of an Ordered List (Template Files) public interface Ordered...

    I need help with the Implementation of an Ordered List (Template Files) public interface OrderedStructure { public abstract int size(); public abstract boolean add( Comparable obj ) throws IllegalArgumentException; public abstract Object get( int pos ) throws IndexOutOfBoundsException; public abstract void remove( int pos ) throws IndexOutOfBoundsException; public abstract void merge( OrderedList other ); } import java.util.NoSuchElementException; public class OrderedList implements OrderedStructure { // Implementation of the doubly linked nodes (nested-class) private static class Node { private Comparable value; private...

  • Java implement the method in IteratorExercise.java using only list iterator methods: bubbleSort: sort the provided list...

    Java implement the method in IteratorExercise.java using only list iterator methods: bubbleSort: sort the provided list using bubble sort Do not modify the test code in each function. You can look at that code for some ideas for implementing the methods. import java.lang.Comparable; import java.util.*; public class IteratorExercise {       public static <E extends Comparable<? super E>> void bubbleSort(List<E> c) throws Exception {        // first line to start you off        ListIterator<E> iit = c.listIterator(), jit;...

  • 1. Implement Doubly Linked List get method which behaves like the operator [] of array. -...

    1. Implement Doubly Linked List get method which behaves like the operator [] of array. - It takes an integer parameter i as the index, it throw an Exception if the index i is illegal, returns the element at given index i, it traverse from the header of the list if index i is in the lower end of the list(less than half of the size), and traverse from the trailer of the list if index i is in the...

  • Plz help me with the code. And here are the requirement. Thanks!! You are required to...

    Plz help me with the code. And here are the requirement. Thanks!! You are required to design and implement a circular list using provided class and interface. Please filling the blank in CircularList.java. This circular list has a tail node which points to the end of the list and a number indicating how many elements in the list. And fill out the blank of the code below. public class CircularList<T> implements ListInterface<T> { protected CLNode<T> tail; // tail node that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT