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

  Code for a sequential search and a binary search

I have code for a sequential search and a binary search. I have to "add a counter for every key comparison in each search function and print out the number of key comparisons for each search."

  Prepare a recursive linear-time algorithm

Prepare a recursive linear-time algorithm that tests whether a binary tree satisfies the search tree order property at every node.

  Taxonomy tree as its input and returns a string

Designing an algorithm that takes a taxonomy tree as its input and returns a string that contains the type of "item" (animal, plant, etc) that was found after traversing the tree.

  Question 1you are required to undertake a detailed analysis

question 1you are required to undertake a detailed analysis of the avl tree sorting algorithm for avlsort.to do this

  Write a script that checks the day of the week

Write a script that checks the day of the week, and takes one of two actions depending on the day. If the day is Monday through Friday, print the name of the day.

  Saving contents of the richtextbox by creating a program

Create the statements to save the contents of the RichTextBox named rtbCurrent. Show a SaveFileDialog named sfdCurrent to get the name of the document from the user.

  Create a two dimensional array called matrix

Create a two dimensional array called Matrix1 of size 3X3. Declare another array of same size called Matrix2. Transpose the contents of Matrix1 into Matrix2.

  Determine the benefits of data mining to the businesses

Determine the benefits of data mining to the businesses when employing - Predictive analytics to understand the behavior of customers

  Show how to compute prefix sum in constant time using pram

Given a sequence of numbers {a1, a2, ... , an}, show how to compute the prefix sum in constant time using PRAM. Which PRAM is used, how many processors are needed, and what is the cost of this algorithm?

  Describe a computation of the timer-based protocol

Describe a computation of the timer-based protocol in which the receiver opens a connection upon receipt of a packet with a sequence number greater than zero.

  Write an algorithm using pseudo code

Write an algorithm, using pseudo code, "Consensus algorithm": A group of ten people need to decide which one flavor of ice cream they will all order, out of three options.

  Definition of a method isreverse

Provide the definition of a method, isReverse , whose two parameters are arrays of integers of equal size. The technique returns true if and only if one array is reverse of the other.

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