EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
数据库代写
您的位置: 主页 > 编程案例 > 数据库代写 >
数据库代做:Data Structures代写 Exam代写 recursive function calls代写 - 代做数据库
发布时间:2021-07-24 15:26:49浏览次数:
Comp 271: Data StructuresData Structures代写 20 points possible (0.3 pts/ question unless noted)11 pages, 1 hr 40 min time (~9 mins / page).Please pace appropriately.  Name: Exam I Data Structures代写20 points possible  (0.3 pts/ question unless noted)11 pages, 1 hr  40 min time (~9 mins / page).   Please pace appropriately.When asked for time or space requirements, use Big-O notation.Use ‘n’ for the number of items in the collection/arrayIMPORTANT NOTE: for numbered problems, if you answer and receive no partial credit, you will be deducted up to an additional 0.3 pts. public static int recFunc (int n) {  if (n 0) {    return (n * recFunc(n-1));  } else {    return (1);} What value does recFunc return?  Give an example.Data Structures代写 How much time, in Big O notation, does recFunc take? For each recursive call, O(1) memory must be stored.  In Big-O notation, how much memory is necessary to compute the solution for the value ‘n’?After running the following four lines of code, answer the questions below:String A = new String(“Jack”);String B = new String(“Jack”);String C = B;Does ‘A == B’ evaluate to true or false?Does ‘B == C’ evaluate to true or false?6 Does ‘A.equals(“Jack”)’ evaluate to true or false?Does ‘A.equals(C)’ evaluate to true or false?ArrayDeque implements the Deque interface, which is a subinterface of Queue.1.Given the information above, circle the following methods you can expect ArrayDeque to implement..contains(Object o).get(int index).peek().add(Object o)What Java collection implementation can use all four of the methods above?3.Collections only store objects, not primitives.  However we have stored integers in collections in the homeworks.  Explain very briefly how this is possibleYou have an empty stack, myStack.  After running the following methods, what letter is remains in the Stack.myStack.add(“A”);myStack.add(“B”);myStack.remove(); Define encapsulation ORgive a real world example of it Order the following big O’s from fastest to slowest.You will use this list for the next two questions.Data Structures代写O(n log n), O(n2), O(2n ), O(log n), O(1), O(n!), O(n)Draw a line dividing the speeds in the answer above where an algorithm becomes impractically slow for ‘n’ in the thousands or more.In the list above, pick one of the Big-O functions above for the letters below: (1.2 pts)a) The time for the fastest sort for a shuffled, random arrayb) The number of times you can subtract 100 from the number ‘n’c) A brute-force search of city-routes to find the shortest pathd) The number of times you can cut a number ‘n’ in half before it reaches 1e) The speed of finding a value in an array, given the indexf) The typical speed of insertion sort, selection sort, and bubble sort.1.What is an advantage of using ArrayList instead of arrays to store values?2  Why should you use arrays instead of ArrayList if it is not too difficult to do so?  What advantage do arrays have over ArrayList?Give a real-world example for either a LIFO queue or a FIFO queue, and indicate which one you picked.To following code clocks the amount of time it takes to run the following for loop ‘num2Check’ times.  Rewrite the last line of code so it prints the average time per lookup, rather than the total time.  You can rewrite it as two lines if you prefer.long startTime = System.CurrentTimeMillis();for (int i = 0; i num2Check; i++) {  if myColl.contains(geneSeq())       System.out.print("Found it!");long totalTime = System.CurrentTimeMillis() - startTime; System.out.print("It took " + String.valueOf(totalTime) + " ms");We often sacrifice space for speed.  Quick sort and merge sort have minimum space requirements beyond the arrays themselves.  What are they?  (hint: quick sort’s memory comes from the recursive function calls – how often is this done in Big-O?  Merge sort requires space to copy half the data array)Data Structures代写There is a shuffled set of ‘n’ cards on a table.  You pick from the top of the deck, and insert it in the proper location in your hand so that your hand is always sorted.  You do this until you have all the cards are sorted in your hand.1 What is the name for this kind of sorting algorithm?Data Structures代写In this analogy, we will alter the algorithm from class.  Unlike the sort we learned in class, instead of looking at your hand from right to left to find the proper location to place the card (a potentially O(n) operation) and then inserting, you are more likely in this case to “intelligently search” the cards in your hand (in the same way your search in a dictionary for a word) since the cards in your hand are sorted.2  What is the big O for inserting one card in your hand this way? (note, this is not an array, but literally a hand full of cards)3  How many times, in big O notation, will you be performing the insertion in the problem above?4 Given the answer to the last two problems, how long does it takes to sort the entire deck of ‘n’ shuffled cards this way in big-O?5  It would appear that the above big O time complexity is not the same as the array implementation of the same sort. Explain the discrepancy. (0.6 pts)6 In the “deck of cards” analogy, we’re doing a binary search to find the location to place the card. Note, sorting an already-sorted deck will be slower than the expected O(n) for the standard array implementation of this sort. Why? (0.5 pts)In the sorts homework we used merge sort and insertion sort on a mixture of two different types of data nearly-sorted arrays and shuffled arrays.1   Write the big-O of each in the following table (0.8 pts)Shuffled nearly-sortedMerge sort O(             ) O(                 )Insertion Sort O(             ) O(                 )When you add the amount of time two different operations take, the big O is the time for the slower operation (e.g. O(n2 ) + O(n3 ) = O(n3 ) ).  Half of the test data was shuffled, and half was nearly-sorted.  Use this information to answer the following two questions.Data Structures代写2  What is the big-O for merge sort on the mixed test data?3  What is the big-O for insertion sort on the mixed test data?4  What is the big-O for a hybrid sort method that efficiently sends nearly-sorted data to insertion sort, and shuffled data to merge sort?5 Give one good reason why it is better to use big-O notation for speed of algorithms, rather than counting operations or using other benchmarks.6  For a given set of data, an O(n) algorithm may not necessarily be faster than an O(n2) algorithm.  Explain why.1  What is wrong with the following code ?(hint: note A and B are objects, not primitives)A = new String(“Adam”);B = new String(“Amanda”);if (A B) {System.out.println(A + “ is alphabetically earlier than “ + B);}Bubble, selection, and insertion sort are all significantly slower sorts than quick sort and merge sort for shuffled data, however,Data Structures代写2  what advantage do they all share relative to those faster sorts?3  Why, with modern computer hardware, is this often not enough of an advantage to use the slower three in practice?In the lecture we discussed an implementation of quick sort that picks the leftmost value as the pivot. This leads to slow behavior if you use quick sort on sorted arrays because it doesn’t ‘divide and conquer’ your array around the pivot appropriately.4  Again, what is the Big O in the case that you have a sorted array?5  What is the big-O for sorted arrays if you pick the middle index as the pivot instead?6  What would you expect to be the big-O if you picked a random index to pivot from?1  Define only one of the following: wrapper class, boxing, unboxing, autoboxing  Data Structures代写2  This swap function doesn’t work, very briefly mention why (0.5 pts)public static void swap (int a, int b) {int temp = a;a = b;b = temp;}3   rewrite the swap function so it does work, swapping values in an array of integers (partial credit will be given to improper syntax if it is conceptually reasonable) (0.5 pts)In the homeworks we used ArrayList to perform array-like operations.  ArrayList uses methods to do the same things we did with indexed arrays.  Translate the following ArrayList commands into an equivalent array commandExamples:myArr.size();     à myArr.length;ArrayList Integer myArr = new ArrayList Integer (50);   à int [] myArr = new int[50];1 myArr.get(i);2 myArr.set(j, 256);3 myArr.set(k, myArr.get(k) + myArr.get(k + 1));In the StackSet implementation, we extended ArrayList to be both a Queue and a Set.4  Is a Stack a FIFO or LIFO queue?Data Structures代写5  Name at least one function we would have had to override to get the Set functionality in the case we were extending LinkedList.1.What is hashing?2.Why is hashing useful?The following are descriptions of functions performed on collections.  However, you don’t have to always specify the specific implementation when it only relies on functions that are stipulated in an interface e.g. Collection, Queue, Deque, List.Name the most general interface (the most “super” interface) you can use for the following functions.3  Iterating through the collection using the index, and printing out each value.4  Iterating through the collection using an iterator, or a for-each loop5  Storing numbers that are assigned to customers as they walk in the store, then picking the number of the person that has been waiting the longest6  Checking to see if a particular value is in the collection, and if not, adding it to the collection.7   Sort the collection (hint: you can only sort collections that you can access based on position).Data Structures代写The following code is a poor implementation of bubble sort, but it does sort the list.public static void listBubbleSort(List x) {       int n = x.size();       for (int pass=1; pass pass++) {      for (int i=0; i i++) {                   if (x.get(i) x.get(i+1)) {                            swap(x, i, i+1);                 }    }

所有的编程代写范围:essayghost为美国、加拿大、英国、澳洲的留学生提供C语言代写、代写C语言、C语言代做、代做C语言、数据库代写、代写数据库、数据库代做、代做数据库、Web作业代写、代写Web作业、Web作业代做、代做Web作业、Java代写、代写Java、Java代做、代做Java、Python代写、代写Python、Python代做、代做Python、C/C++代写、代写C/C++、C/C++代做、代做C/C++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。