



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




A quadratic algorithm, O(n^2), takes 10^3 sec to complete a task on the input size of 106 elements. What should the input size be for this algorithm to complete the same task in 4 · 10^3 sec? - ANS210^ Abstract Data Type (ADT) - ANSA theoretical model of a data structre Assume that Counting Sort Algorithm is applied to sort one million SSN's; why would this be impractical? - ANSToo much memory! Bubble Sort does how many comparisons? - ANS(n-1)^ Can an element of a dynamic array allocated on heap memory be access explicitly using [ ]? - ANSYes! Consider the C++ statements: int ip = new int[3]{1,2,3}; cout << (ip)++; What value is displayed by the cout statement? - ANS Consider the C++ statements: int ip = new int[3]{1,2,3};
cout << (++ip); What value is displayed by the cout statement? - ANS Consider the C++ statements: int ip = new int[3]{1,2,3}; cout << (ip++); What value is displayed by the cout statement? - ANS Consider the C++ statements: int ip = new int[3]{1,2,3}; cout << ++(*ip); What value is displayed by the cout statement? - ANS Debugger - ANSIt is a misconception that debuggers make large programs more time efficient; they do not Dynamic Array - ANSStores input data on the stack computer memory For a resize_array() function, what is the correct formula to determine the number of resizes for n elements where n is an exact power of 2? - ANSlog_2(n)
True or false: The binary and linear search algorithms take the same number of comparisons to find the target in the worst case. - ANSFalse What data structure should be used to reverse input data? - ANSStack What is the big-O classification of Bubble Sort? - ANSO(n^2) What is the complexity of the Binary Search algorithm that runs on sorted input? Assume that n is the input size. - ANSO(log_2(n)) What is the conclusion from the "Lower Bound Theorem" for the comparison based sorting algorithms? - ANSNo one can design a comparison based sorting algorithm with the number of comparisons lower than nlog_2(n) in the worst case. What is the formula for the number of comparisons Selection Sort makes? - ANS[(n-1)(n)]/ What should the class do if a private data member is declared as a pointer? - ANSCreate a copy constructor (and the remaining of the Big 5) to avoid creating a shallow copy What type is: int ip = new int(5);? - ANSA pointer to type int. Where does the variable ip: int* ip = new int(5); reside in computer memory? - ANSStack. Not the heap...
Which data structure should be used for the simulation of replenishing bottles of milk in grocery shelves? - ANSQueue Which sorting algorithm contains the insertion sort as part of it? - ANSBucket Sort Which statement is true about the algorithm below? The running time function f (n) provides a formula for the number of operations (additions and assignments) done on the variable sum. The Big-O asymptotic notation is used to classify the algorithm based on the function f(n). Assume that the value of n is the exact power of 4. sum = 0; for (int i = 1; i < n; i*=4) sum = sum + 1; - ANSf(n)=2log_4(n)+ f(n)=O(log_2(n)) Which unstable sorts have we discussed? - ANSBucket and Selection