Csc 220.01 Assignment Instructions
ASSIGNMENT INSTRUCTIONS 1. Assignment 02: 50 points w/ 5 E.C. points 2. Due Date & Time: at 11:55 PM WHAT TO SUBMIT 1. Assignment Report 2. Code HOW TO SUBMIT • Please refer to the “Guidelines for All Assignments” and the “Assignment Report Template” which we discussed in detail in assignment 00. Please download: PART A – The Bag, 20 points Define the method removeAllOccurrences for the class LinkedBag that removes all occurrences of the given entries from a bag. Your program’s output must be identical to this output: PART B – The Efficiency of Algorithms, 10 points 1. Show how you count the number of operations (not only basic operations) required by the algorithm, 4 points: sumList(aList, n) { thisSum = 0; lastSum = 5000; for (int i = 0; i = n; i++) { thisSum = thisSum + aList[i] * 2; } return thisSum = lastSum; } 2. Consider the following two loops, 4 points: // Loop A for (i = 1; i = n; i++) for (j = 1; j = 10000; j++) sum = sum + j; // Loop B for (i = 1; i = n; i++) for (j = 1; j = n; j++) sum = sum + j; Although Loop A is O(n) and Loop B is O(n2 ), Loop B can be faster than Loop A for small values of n. Design and implement an experiment to find a value of n for which Loop B is faster
Document information
- Uploaded on
- March 5, 2023
- Number of pages
- 2
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers