Which of the following is true?
ArrayLists are constructed of nodes that include elements and
references to other elements
LinkedLists are constructed of nodes that include elements and
references to other elements
ArrayLists are, by definition, lists of arrays
LinkedLists are, be definition, lists of links
Which of the following statements is correct in most cases?
Accessing an element in an array by index is less expensive than
accessing an element by index in a LinkedList
Accessing an element in an array by index is less expensive than
accessing an element by index in an ArrayList
Accessing an element in an array by index is more expensive than
accessing an element by index in a LinkedList
Accessing an element in an array by index is more expensive than
accessing an element by index in an ArrayList
Which of the following statements is correct in most cases?
Adding an element to the beginning of an ArrayList is less
expensive than adding an element to the beginning of an array
Adding an element to the beginning of an ArrayList is less
expensive than adding an element to the end of an ArrayList
Adding a node to the beginning of a LinkedList is less expensive
than adding an element to the beginning of an ArrayList
Adding an element to the beginning of an ArrayList is less
expensive than adding a node to the beginning of a LinkedList
The O in big-O notation stands for
zero
"order of"
"ordinal"
"original"
Solution:
Q1) Which of the following is true?
Ans)
LinkedLists are constructed of nodes that include elements and
references to other elements
Q2) Which of the following statements is correct in most
cases?
Ans)
Accessing an element in an array by index is less expensive than
accessing an element by index in a LinkedList
Accessing an element in an array by index is less expensive than
accessing an element by index in an ArrayList
Q3) Which of the following statements is correct in most
cases?
Ans)
Adding an element to the beginning of an ArrayList is less
expensive than adding an element to the beginning of an array
Adding a node to the beginning of a LinkedList is less expensive
than adding an element to the beginning of an ArrayList
Q4) The O in big-O notation stands for
Ans) "order of"
Which of the following is true? ArrayLists are constructed of nodes that include elements and references...
java
Create the following classes: DatabaseType: an interface that contains one method 1. Comparator getComparatorByTrait(String trait) where Comparator is an interface in java.util. Database: a class that limits the types it can store to DatabaseTypes. The database will store the data in nodes, just like a linked list. The database will also let the user create an index for the database. An index is a sorted array (or in our case, a sorted ArrayList) of the data so that searches...
JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class. Print out the results after testing each of the methods in both of the classes and solving a simple problem with them. Task 1 – ArrayList Class Create an ArrayList class. This is a class that uses an internal array, but manipulates the array so that the array can be dynamically changed. This class should contain a default and overloaded constructor, where the default...
I also don't quite understand the meaning of N.size, is N.size
(the sum of nodes) (a node and its sub trees) has? please also
explain that, thank you.
modify the standard definition of a binary search tree to add a field N.size at each Suppose that we node, which records the size of the subtree under N'Tincluding N itself). A. Explain how to modify the procedure for adding both the case where X is not yet in the tree and...
In this assignment, you will use a Hashtable to determine the
common elements in all the lists. If an element appears more than
once in one or more lists, the algorithm should capture the
instances the element is present in all the lists.
You are given a code that implements a Hashtable as an array of
linked lists. You are also given a main function that will create
an array of Lists using the input variable values that you enter....
Please use Java programming: Modify both ArrayList and LinkedList classes and add the following method to both classes: public void reverseThisList(), This method will reverse the lists. When testing the method: print out the original list, call the new method, then print out the list again ------------------------------------------------------------------------- //ARRAY LIST class: public class ArrayList<E> implements List<E> { /** Array of elements in this List. */ private E[] data; /** Number of elements currently in this List. */ private int size; /**...
Add the following methods to the ArrayList class that we wrote during lecture. You may call the existing methods in ArrayList if you want, but do not use anything from the built-in java.util.ArrayList class. 1. (3 pts) Write a new method named addAll(ArrayList anotherList) that adds all the elements in anotherList to the back of the calling list. Be sure to reallocate the data array if necessary. anotherList should not be modified. 2. (4 pts) Write a new method named...
12. Which of the following is not a property of LinkedListNode? a.Value b.Reference c.Previous d.Next 13. Which of the following statements is false? a.Lambda expressions allow you to define simple, anonymous methods. b.A lambda's return type is listed to the left of the lambda. c.A delegate can hold a reference to a lambda expression that has a signature that's compatible with the delegate type. d.A lambda expression is called via a variable that references it. 15. In functional programming, you...
1.3 Which of the following is true about sorting functions?A.The most optimal partitioning policy for quicksort on an array we know nothing about wouldbe selecting a random element in the array.B.The fastest possible comparison sort has a worst case no better than O(n log n).C.Heapsort is usually best when you need a stable sort.D.Sorting an already sorted array of size n with quicksort takes O(n log n) time.E.When sorting elements that are expensive to copy, it is generally best to...
JAVA Lab Create a class called ArrayBasedStack. Declare the following variables: • data: references an array storing elements in the list • topOfStack: an int value representing the location of the stack top in the array • INITIAL_CAPACITY: the default capacity of the stack public class ArrayBasedStack <E> { private E[] data; private int topOfStack; private static final int INITIAL_CAPACITY = 5; } Add a constructor that will initialize the stack with a user-defined initial capacity. The top of the...
Question 16 Which of the following elements is the root for the word dermatitis? -itis -matitis der- dermat- de- Question 17 Which of the following statements is NOT true of combining vowels? Combining vowels can join a root to another root. Examples of combining vowels are "o" and "a." A combining vowel has no meaning of its own. A combining vowel makes a word easier to pronounce. The most commonly used combining vowel is "u" followed by "i." Question 18...