Is it better to use an arraylist or a linkedlist

Assignment Help Data Structure & Algorithms
Reference no: EM131344091

Question 1

Which of these data structures allow duplicate values? Choose all that apply.

Queue

Set

Priority queue

List

Question 2

Which of these data structures is most similar to a dictionary, in which more information about an entity is retrieved based on its key?

Stack

Set

Priority queue

Map

Question 3

If you add several objects to a HashSet and it appears that there are multiple copies of the same item, what have you most likely forgotten to do?

override toString()

declare a class field as the key

override equals() and hashcode()

implement Serializable

Question 4

In order to use a TreeMap, which of the following must be true?

the keys must be a class that implements Comparable or you must pass the TreeMap constructor a Comparator for the key objects

the values must be a class that implements Comparable or you must pass the TreeMap constructor a Comparator for the value objects

the keys must be numeric

all of these

Question 5

Which of these is approximately the largest value of n that is feasible for an exponential algorithm on modern computers?

n=3

n= 30

n=300

n=3000

Question 6

What is the time complexity of this method?

public static intnumberOfLargest(int[] data)

{

int max = Integer.MIN_VALUE;

int count = 0;

for (int d: data)

{ if (d > max) { max = d; } }

for (int d: data) { if (d == max) { count++; } }return count;}

constant

quadratic

logarithmic

linear

Question 7

What is the time complexity of this method? public static void printMultiplicationSquare(int n) { for (inti=1; i<= n; i++) { for (int j=1; j<=n; j++) { System.out.print(i*j + "\t"); } System.out.println("\n"); }}

constant

quadratic

logarithmic

linear

Question 8

You need to choose a sorting algorithm that is as fast as possible, and memory space is in short supply. Which of these is the best choice?

bubble sort

merge sort

heap sort

they are all equivalent

Question 9

Which of these sorting algorithms only works on integers? Choose all that apply.

quick sort

bucket sort

heap sort

radix sort

Question 10

What does this array look like after the first pass of bubble sort? Assume the values are being sorted into ascending (smallest-to-largest) order.

15, 27, 3, 9, 17, 46, 14, 22, 8

15, 27, 3, 9, 17, 14, 22, 8, 46

15, 3, 9, 17, 27, 14, 22, 8, 46

3, 8, 9, 14, 15, 17, 22, 27, 46

15, 27, 3, 9, 17, 8, 14, 22, 46

Question 11

Which of these are characteristics of a heap? Choose all that apply. (Be careful not to confuse heaps with binary search trees.)

each node has at most two children

every node is greater than both of its children

every node is larger than its left child and smaller than its right child

the largest value is in the bottom-right node

You need to write a program that frequently adds and removes items at the beginning of a list. Is it better to use an ArrayList or a LinkedList?

ArrayList

LinkedList

the choice doesn't matter in this case

Question 13

You need to write a program that frequently retrieves items from specific indices in a list. Is it better to use an ArrayList or a LinkedList?

ArrayList

LinkedList

the choice doesn't matter in this case

Question 14

You need to write a program that frequently iterates through all the items in a list. Is it better to use an ArrayList or a LinkedList?

ArrayList

LinkedList

the choice doesn't matter in this case

Question 15

If an ArrayList has reached its capacity and you try to add another item, there is a performance hit while a new, larger list is created and the values from the current list are copied over to it. How can this delay be avoided?

add all the items at once

set the initial capacity of the list to an estimate of the number of items it will need to hold

multi-thread your application

add items to the beginning rather than the end of the list

Question 16

What is the third value in the breadth-first traversal of this binary search tree?

2

7

14

23

Question 17

What is the third value in the inorder traversal of this binary search tree?

12

14

10

23

Question 18

What is the third value in the preorder traversal of this binary search tree?

12

14

2

16

Question 19

What is the third value in the postorder traversal of this binary search tree?

23

46

12

16

Question 20

LinkedHashSet

HashSet

TreeSet

1. Very efficient; items are stored unordered

2. Items are stored in the order they are added

3. Items are stored in their 'natural' ordering

Question 21

Match the following complexity terms with their Big-O notation.

Constant

logarithmic

cubic

exponential

linear

quadratic

6. O(2n)

Question 22

Put the following time complexities in order from smallest to largest.

cubic

constant

linear

quadratic

exponential

logarithmic.

Reference no: EM131344091

Questions Cloud

Determine the magnitude of the pin reaction at b : The weights and lengths of the two homogeneous beams that make up the structure are shown in the figure. Determine the magnitude of the pin reaction at B.
Assignment - aggression and violence in the media : Assignment: Aggression and Violence in the Media. Reflect on two to three (2-3) TV shows in which characters demonstrate aggression or violence. Consider the context in which this aggression or violence occurred and ways in which it can lead to de..
Annual operating cash flow : "Mike is looking at a project that has an annual operating cash flow of $45,000. Initially, this four-year project required $3,800 in net working capital, which is recoverable when the project ends. The firm also spent $21,500 on equipment to start t..
Philosophies integrated in your current classroom : What learning methods and philosophies apply to the age/grade you are teaching - How are these learning methods and philosophies integrated in your current classroom?
Is it better to use an arraylist or a linkedlist : What is the time complexity of this method? You need to write a program that frequently iterates through all the items in a list. Is it better to use an ArrayList or a LinkedList?
Summarize the statistics from the last two reporting years : Summarize the statistics from the last two reporting years. Be sure to include demographic information such as ethnicity, race, age, gender, marital status, employment status, socioeconomic group, etc., and moderator variables related to the crime..
Write company overview on tootsie roll industries : What the company is about, what they do, major development, recent development, how the organization is structured e.t.c.
How you will use the information as a teacher : Research four articles, two on typical language development, and two on atypical language development. In a 500-750 word essay, summarize the articles and reflect upon how you will use the information as a teacher.
Brief description of two conditions in the media : Assignment - A brief description of two conditions in the media that led to conformity and explain why. Using the current literature, explain one way to alter the conditions in the scenario to prevent conformity. Finally, provide an example where ..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Convert a sorted double-linked list to a binary search tree

Write a program to convert a sorted double-linked list to a binary search tree - Find the middle node in the doubly linked list and set it as root, convert the left sublist and set it as left subtree, convert the right sublist and set it as right s..

  Developing an eer model

Construct an EER model for the given situation using the traditional EER notation, the Visio notation or the supertypes notation.

  Program to convert this temperature in centigrade degree

Temperature of city in Fahrenheit degree is input through the keyboard Draw a flow chart; write an algorithm and program to convert this temperature in centigrade degree.

  Powerpoint presentation with the focus on stress management

Assume you have been asked to help new students identify ways in which they can manage their time so that they can be successful in an online learning environment.

  For what values of d is the tree t

For what values of d is the tree T of the previous exercise an order -d B-tree? HINT: The definition of an order- d  deals with the minimum and maximum number of children an internal node can have.

  Briefly define the caesar cipher

What are the two basic functions used in encryption algorithms and how many keys are required for two people to communicate via a cipher?

  Describe a polynomial time algorithm

Describe a polynomial time algorithm that solves the following decision problem: Given a graph G and an edge f in it, does G have a cycle containing f?

  Problems on edges and graphs

Suppose if we add an edge to a biconnected graph with k strongly connected components, then there are 3-situations: the endpoints of edge lie in different strongly connected component and there is no path between 2 in the original graph,

  Selection sort algorithm

Given the algorithm below for SelectionSort, trace the function by specifying the state of the input sequence after each call to swap()

  Diagram of a telephone network

Consider a diagram of a telephone network, which is a graph G whose vertices represent switching centers, and whose edges represent communication lines joining pairs of centers. Edges are marked by their bandwidth, and the bandwidth of a path is the ..

  Identify a common task that might occur regularly

Identify a common task that might occur regularly. The task should be one that might occur in a business setting rather than one in someone's personal life.

  Find the longest increasing sub sequence

The longest Increasing Sub-sequence (LIS) problem is to find the length of the longest sub-sequence of a given sequence such that all elements of the sub-sequence are sorted in increasing order.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd