ECE 198
Sample Midterm Exam
Student Taking The Exam
Name: ____________________________________________ID:____________________
Signature of Student seated in front of you (or get TA signature if first in row)
___________________________________________________________________
Signature ofStudent seated behind of you (or get TA signature if last in row)
___________________________________________________________________
- Be sure to bring picture ID, such as CDL or UCI id, to all exams!
- Verify identity with the person in front of you and the person behind you. Check that their name and picture match who they are before you sign their exam.
- Sit in corn rows so you are directly behind the person in front of you and there is an empty seat to each side of you.
- REMINDER: cheating will result in an F course grade, a letter in your permanent record, and possible expulsion from UCI.
- The exam involves writing complete class definitions (C++, Java, Python, or C#). Declare any member variables needed, and write a constructor for each class. Write any additional classes you need. Do not use any definitions other than those you write on the exam except basic class definitions like string and its standard methods. You need not write destructors.
- Each method will be graded separately. Please DO NOT comment your code. If you need more space than is provided, continue on the back, and indicate the number of the problem to which the continuation belongs. You must write the average time complexity in big-O notation next to EVERY method you write EXCEPT the constructors. You do not need to give private or public declarations, but, if you do, they must be correct.
- Use the names specified on the exam for methods and variables, etc, but you must choose good names for parameters and local variables whose names are not specified in the problem statement.
- Each question will be graded as follows:
- The maximum score for the entire exam is 100 points.
- If you are missing a method or if a method is mostly wrong, you lose 10 points. Any question unanswered will result in an immediate total point deduction. Otherwise you will lose points according to the following criteria up to the maximum question value.
- ALGORITHMIC CORRECTNESS (-3 for each logic error)
- AVERAGE TIME COMPLEXITY (-3 for each one that is incorrect)
- EFFICIENCY (-3 for each efficiency error. You must use the most efficient algorithm presented in lecture for each method I ask you to write, and I don't want you calling the same function more than once unnecessarily - instead, save the value in a local variable.)
- (30 points) Write the entire class definition for class UnorderedArrayList. Define the member variables, the constructor, which constructs from a specified capacity, and write the following three methods: insert which takes one string parameter, s, and places that in this ArrayList, find which takes one string parameter, s, and returns true only if s is in this ArrayList, and remove which takes one string parameter, s, and removes that string from this ArrayList. Do not forget the average time complexities (You should use N as the number of items in this ArrayList).
- (10 points) Assume you write a function that reads N words into your UnorderedArrayList, then removes them each, one at a time. What is the time complexity of this function.
- (30 points) Write the entire class definition for class UnorderedLinkedList. Define the member variables, the constructor and write the methods insert, find, and remove. Do not forget the average time complexities.
- (10 points) Assume you write a function that reads N words into your UnorderedLinkedList, then removes them each, one at a time. What is the time complexity of this function.
- (10 points) How large should you make the UnorderedArrayList if you have a pretty good idea that N will not exceed M?
- (10 points) Explain the paradox of why OrderedLinkedList appeared to perform very fast in the homework problem. Insert is O(1) so inserting N words is O(N). remove is O(N) and removing N words should be O(N*N), but when you inserted each word from random.txt, then removed each word from random.txt, it seemed remove was just as fast as Inserting N words.
program you wrote,
- (10 points) bonus Read the entire page at the web link below. Which of the following are true about this student:
- ECE 198 Student's Post
- a) this is a very serious form of cheating
- b) this students permanent record will contain a letter indicating a cheating incident
- c) this student is likely to earn an F course grade
- d) this student could be expelled from ECE major
- e) this student could be expelled from UCI
- f) this student's parents will be proud that they solved their homework this way
- g) this student's future employers will be elated that that they bought homework solutions
- h) this student is a world-wide embarrassment to UCI
- i) all of the above
- j) none of the above