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

  Data information decision

Data Information Decision

  Relationships in a database model

Discuss different types of classifications and do they overlap, or do they each tell us something unique about the entity relationship?

  Find combination of projection and inverse projection map

Find the combination of projection and inverse projection maps which finds all authors by whom I have horror books

  Write a program that implements dijkstras algorithm

Write a program that implements Dijkstra's algorithm

  Use wildcard characters for search

You can't search for the opening and closing brackets ([ ]) together because Microsoft Access interprets this combination as a zero-length string. You must enclose the opening and closing brackets in brackets ([[ ]]).

  Algorithm to take input m constraints over n variables

For instance, the constraints x1 = x2, x2 = x3, x3 = x4, and x1 6= x4 cannot be satis fied. Give an efficient algorithm that takes as input m constraints over n variables and decides whether the constraints can be satis fied.

  Implement a method to delete every node

Call the structure for the nodes of the tree WordNode, and call the references in this structure left and right. Use Strings to store words in the tree. Call the class implementing the binary search tree WordTree.

  Refresh address counter

A microcomputer memory is built from 64K X 1 DRAM, with DRAM cell array organized into 256 rows. Each row requires being refreshed at least once every four ms, strictly on a periodic basis.

  Multilayer protocol in the sense of the osi reference model

The president of company A decides that company A should work with company B to develop a new product. The president tells her legal department to look into the idea, and they in turn ask the engineering department for help.

  Develop the flow diagram of the information

Develop the flow diagram of the information and any control elements needed to ensure proper access for the information. A diagram of the information flow and any elements controlling proper access to the information it uses

  Draw the hierarchy chart and then plan logic for a program

Draw the hierarchy chart and then plan the logic for a program for the sales manager of The Couch Potato Furniture Company. The manager needs a program to determine the profit on any item sold

  Algorithm devise a test plan that will ruthlessly locate

Explain using text and diagrams how your algorithm works. Imagine that you later leave the software company producing the bespoke spread sheets and a new scripter takes over your work. If you were that new scripter what information would you find ess..

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