ReviewQuestions.docx

# 5 give the change to line 7 of an unsorted array

• Notes
• 11

This preview shows page 5 - 6 out of 11 pages.

5. Give the change to Line 7 of an Unsorted Array structure’s Fetch algorithm to unencapsulate the structure after the Fetch operation is completed. a. Return Arrays.copyOf(data, data.length) Return System.arraycopydata Return data.clone(); 6. A data structure is to be chosen that will allow the customers to look up the price of an item, given its item number. The data set will only be loaded once and never modified. Of the three array-based structures discussed in this chapter, which would be best suited for this application? a. Unsorted-Optimized Array

Subscribe to view the full document.

7. The Sorted Array structure accesses nodes using the Binary Search algorithm, and the Unsorted-Optimized Array structure uses a Sequential Search to access nodes. Knowing that a binary search is significantly faster than a sequential search, explain why it is that the average speed of the Unsorted-Optimized array structure is faster than that of the Sorted Array structure. (Assume all four basic operations are equally probable.) a. The average speed of the unsorted optimized array structure is faster than that of the sorted array structure because in sequential search the list need not be sorted and if the target is the first element in the list then it is the best case the element is found at the first position, if not we need to scan and search all the elements. On the other hand, binary search is complicated when compared to sequential because the list in binary search must be sorted and even if the target is at the first position, then also we have to check the average cases. 8. Referring to the data structure depicted in Figure 2.8, what memory location would be returned by the Fetch algorithm is Mike’s node was requested and the structure was not encapsulated? 9. Give the differences in the basic operation algorithms of the Unsorted and Unsorted- Optimized Array structures that made the latter structure faster. Under what conditions would both structure’s Fetch algorithms be equivalent from a speed viewpoint? a. Both unsorted and unsorted optimized use sequential search, but the latter one After an element is found, it reference is swapped with the element above it, this brings all the most frequenct search elements to the top of the Array thus reducing the Average number of steps required for searching . Deletion: for unsorted: Sequential Search is used to search a Element in the Array to be deleted and all Element which are right to it are movied to left by 1; for unsorted optimized: Modified Sequential Search is used to find an element and only last element right to it is swapped instead of all right elements. 10. The Unsorted-Optimized array structure is used to store a data set. Calculate its density if- a. Each of the client’s nodes contains 8 bytes of information and there are 50 nodes in the data set i. 0.66 b. Each of the client’s nodes contains 200 bytes of information and there are 1,000,000 nodes in the data set.
You've reached the end of this preview.
• Spring '16
• Array data structure

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern