ReviewQuestions.docx

# Encapsulation the idea that we write code in a way

• Notes
• 11

This preview shows page 2 - 3 out of 11 pages.

Encapsulation: the idea that we write code in a way that establishes compiler enforced protocols for accessing the data that the program processes 15. What is the java keyword that encapsulates data inside an object? a. Private 16. Three algorithms A, B, and C, are under consideration for the insert operation od a particular data set. Though an analysis of these algorithms, their speed functions have been determined to be: Algorithm A: 23n + 36n^2; Algorithm B: 6 + nlog2n + n; Algorithm C: log2n + 36n^2 a. Calculate the value of these three functions when = 1,000,000 i. Algorithm A: 3.6000023 E13 Algorithm B: 2.0931574.57 Algorithm C: 3.6 E13 b. Using Big-O analysis, calculate the value of each function c. Determine the percent difference between the values calculated in parts a and b for each algorithm 17. A 1000 element array is used to store integers in ascending order. The array is to be searched using the binary search algorithm for the two integers 5215 and 7282. How many elements the array would be examined by the algorithm to locate a. The integer 5215 stored in element 499? i. 4? b. The integer 7282 stored in element 686?

Subscribe to view the full document.

i. 3? 18. What is the maximum and minimum number of times the search loop will execute when searching through an array of 1,048,576 integers if the search algorithm is a. The binary search? i. Minimum 1, maximum 20 b. The sequential search? i. Minimum 1, maximum 1,048,576 19. Half of the integers stored in the array data are positive, and half are negative. Determine the absolute speed of the following algorithm, assuming: the time to execute a memory access is 100 nanoseconds and that all other operations (arithmetic, register access, etc) take 10 nanoseconds. for (int I = 0; I < 1000000; i++) { if(data[i] < 0) data[i] = data[i] *2; } a. 0.175 seconds 20. Observations of the “traffic” on a data structure over a certain period of time indicate the that 500 Insert operations, 500 delete operations, 700 Fetch operations, and 200 Update operations were performed on a data set. If Insert operations take 10 nanoseconds, Delete operations take 250 nanoseconds, Fetch operations 200 nanoseconds, and Update operations 300 nanoseconds, determine: a. The probability of performing a Fetch operation over the observation period i. 173.7 nanoseconds b. The average speed, in nanoseconds, of the data structure over the observation period i. 2.5 21. Calculate the density of a data structure whose data set consists of 1,000,000 nodes, assuming the structure requires 1,000,000 bytes overhead to maintain itself, and: a. Each node in the data set contains 2000 information bytes i. 0.9995  b. Each node in the data set contains 20 information bytes i. 0.9523 22. Repeat the above exercise assuming the overhead is 10 bytes per node. a. 10,000,000 bytes 23. State the Java code to declare an array of 100 integers named ages. a. Int [] ages = new int [100]; 24. State the Java code to declare an array of three Listing objects named data that are initialized with the no-parameter constructor.
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