Assuming the data structures below have the same number of elements, which would take the longest time to fill? HashSet ArrayList LinkedHashSet TreeSet
Added by William F.
Close
Step 1
Step 1: The question asks which data structure would take the longest time to fill when they have the same number of elements. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 80 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Akash M.
Two sorted lists have been created, one implemented using a linked list (LinkedListLibrary class) and the other implemented using the built-in Vector class (VectorLibrary class). Each list contains 100 books (title, ISBN number, author), sorted in ascending order by ISBN number. Complete main() by inserting a new book into each list using the respective LinkedListLibrary and VectorLibrary InsertSorted() functions and outputting the number of book copy operations the computer must perform to insert the new book. Each InsertSorted() returns the number of book copy operations the computer performs. Ex: If the input is: Title: Their Eyes Were Watching God ISBN: 9780060838676 Author: Zora Neale Hurston The output is: Number of linked list book copy operations: 1 Number of vector book copy operations: 95 Which list do you think will require the most operations? Why? In C++, please.
Suppose we are doing selection and merge sorts on the list below, and that we are operating on a computer where essentially every operation is cost-free (takes 0 time to execute) except for the act of assigning a value into a slot of the list passed in (such as setting V1.set(0, 42);), which requires 100 units of time. (Assigning a value to a normal int variable, or into any other list or collection, requires no time in this hypothetical model.) How long does each algorithm take to run for this particular data under these particular conditions? Which sorting algorithm requires less time to run? Assume that selection does not perform a swap if not necessary, that is, if the two indexes of interest are the same. // index 0 1 2 3 4 5 6 7 // values {15, 56, 24, 5, 39, -4, 27, 10} ArrayList<Integer> v1 = new ArrayList<Integer>(Arrays.asList(15, 56, 24, 5, 39, -4, 27, 10)); selectionSort(v1); ArrayList<Integer> v2 = new ArrayList<Integer>(Arrays.asList(15, 56, 24, 5, 39, -4, 27, 10)); mergeSort(v2);
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD