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...
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',...
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 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...
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...
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....
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.
Write Java program Lab43.java which declares and initializes numeric array of 5 elements (int num[5]) and...
Write Java program Lab43.java which declares and initializes numeric array of 5 elements (int num[5]) and produces as output the sum of integers in an array, the largest and the smallest element in an array. Your program should contain the following methods: public static int sum(int[]) public static int findLargest(int[]) public static int findSmallest(int[])
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT