Question

In: Computer Science

In Java Which of the following is true? a.ArrayLists are constructed of nodes that include elements...

In Java

  1. Which of the following is true?

a.ArrayLists are constructed of nodes that include elements and references to other elements
b.LinkedLists are constructed of nodes that include elements and references to other elements
c.ArrayLists are, by definition, lists of arrays
d.LinkedLists are, be definition, lists of links

  1. Which of the following statements is correct in most cases?

a.Accessing an element in an array by index is less expensive than accessing an element by index in a LinkedList
b.Accessing an element in an array by index is less expensive than accessing an element by index in an ArrayList
c.Accessing an element in an array by index is more expensive than accessing an element by index in a LinkedList
d.Accessing an element in an array by index is more expensive than accessing an element by index in an ArrayList

  1. Which of the following statements is correct in most cases?

a.Adding an element to the beginning of an ArrayList is less expensive than adding an element to the beginning of an array
b.Adding an element to the beginning of an ArrayList is less expensive than adding an element to the end of an ArrayList
c.Adding a node to the beginning of a LinkedList is less expensive than adding an element to the beginning of an ArrayList
d.Adding an element to the beginning of an ArrayList is less expensive than adding a node to the beginning of a LinkedList

  1. Which of the following statements is correct in most cases?

a.Linear search of a LinkedList is less expensive than linear search of an ArrayList
b.Linear search of an ArrayList is less expensive than linear search of a LinkedList
c.Linear search of a LinkedList is less expensive than linear search of an array
d.Linear search of an ArrayList is less expensive than linear search of an array

Solutions

Expert Solution

Which of the following is true?
b.LinkedLists are constructed of nodes that include elements and references to other elements

Linked List is defined as a collection of nodes connected together by their references.

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

Since arrayList uses array internally, so accessing element by index is easier.

Which of the following statements is correct in most cases?

c.Adding a node to the beginning of a LinkedList is less expensive than adding an element to the beginning of an ArrayList

Adding a node at the beginning of the linked list takes O(1) time while adding at the begining of the arrayList takes O(n) time, as all elements have to be shifted to make space for the element to be entered.

Which of the following statements is correct in most cases?
b.Linear search of an ArrayList is less expensive than linear search of a LinkedList

Linear seacth is all about accessing elements by theoir index and since accessing index in arrayList is easier.


Related Solutions

Which of the following statement(s) is(are) true? Select one or more: a. The building constructed by...
Which of the following statement(s) is(are) true? Select one or more: a. The building constructed by the builder can’t serve as collateral on the loan application of builders. b. The land of the building can be treated as security in the loan application of the property developers. c. A wise property developer should start to build properties when the current demand on the market is high. d. A property development loan is bridge finance for the borrower to develop land...
in a decision tree, decision nodes are the nodes in which uncertainty is involved that is...
in a decision tree, decision nodes are the nodes in which uncertainty is involved that is out of the control of the decision maker. do you agree with the statement? explain with examples. projects may vary with the amount of leverage they will support. for example, acquisitions of real estate or capital equipment are often highly levered , whereas investments in intellectual property are not. do you agree with this statement. explain with examples.
Which one ore more of the following statements is/are true of Java? a.LinkedList < T >...
Which one ore more of the following statements is/are true of Java? a.LinkedList < T > and ArrayList < T > are interfaces b.List < T > is a concrete class c.LinkedList < T > and ArrayList< T > are concrete classes d.List < T > is an interface Suppose we run these operations on a queue of characters: enqueue 'a' enqueue 'b' enqueue 'c' dequeue dequeue What remains in the queue after these operations complete? a. 'a' b. 'a',...
Which of the following is true or false 1) Within the Bilateria, the Protostomes include two...
Which of the following is true or false 1) Within the Bilateria, the Protostomes include two major groups of organisms, the Lophotrochozoa and the Ecdysozoa. The segmented worms (Phylum Annelida) molt their outer cuticle and belong to the Ecdysozoa. 2) A major route of evolutionary diversification among the four Classes of the Phylum Cnidaria resulted from the reduction or loss of one phase of the complex life cycle. 3) The basal (“primitive”) Classes of the Phylum Crustacea are characterized by...
In java, Write a recursive function to calculate the sum of the nodes only on even...
In java, Write a recursive function to calculate the sum of the nodes only on even levels of the subtree. please do not add any parameters to do this function. private int sumEvenLevels(Node current){ //you can only pass in root. //code }
In Java Write a method countOddInternalNodes that returns the number of internal nodes in a binary...
In Java Write a method countOddInternalNodes that returns the number of internal nodes in a binary tree that contain odd numbers. You are essentially writing a method that will become part of the IntegerTree class. You may define private helper methods to solve this problem. Make your own trees in the main method of the code. I specifically kept vague the way the nodes are being added to the tree so you can practice building your own trees from scratch...
Find a node in a LinkedList In Java: 1. (2 pts) Define the nodes in the...
Find a node in a LinkedList In Java: 1. (2 pts) Define the nodes in the LinkedList. 2. (2 pts) Create the LinkedList using the ListNode class. 3. (4 pts) Create a method to find a node with given value in a LinkedList. Return the value is this value exists in the LinkedList. Return null if not exists. 4. (2 pts) Use these two examples to test your method. Example 1: Input: 1 -> 2 -> 3, and target value...
Which of the following is a true statement? Which of the following is a true statement?...
Which of the following is a true statement? Which of the following is a true statement? a. The electric potential energy depends on both the electric field and the amount of charge moving through that field. b. The electric potential depends on both the electric field and the amount of charge moving through that field. c. The electric potential energy and the electric potential depend on both the electric field and the amount of charge moving through that field. d....
Answer the following Java questions with True or False: a) Java supports Multiple Inheritance in a...
Answer the following Java questions with True or False: a) Java supports Multiple Inheritance in a way that a class can inherit from multiple classes as long as they do not have the overridden methods. (T/F) b) A class in Java cannot implement more than one interface. (T/F) c) A class is in instance of an object (T/F) d) In Java a class can implement multiple interfaces only if that class inherits from another base class (T/F) e) Constructors are...
Write a binary search tree and include the functions to find the number of nodes and...
Write a binary search tree and include the functions to find the number of nodes and the height of the tree. Test your code in main. Print the post-order, in-order and pre-order traversal. in c++ please.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT