100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Practice Final Simon Fraser University CMPT 225 $6.49   Add to cart

Exam (elaborations)

Practice Final Simon Fraser University CMPT 225

 8 views  0 purchase
  • Course
  • Institution

CMPT 225, Spring 2018, Practice final Instructions: There are 7 questions worth 15 points each. Good luck! 1. Given two doubly linked lists, L 0 and L 00, give the pseudocode for a procedure for merging them into a single doubly linked list L that has all the nodes of L 0 followed by all th...

[Show more]

Preview 2 out of 8  pages

  • April 9, 2023
  • 8
  • 2022/2023
  • Exam (elaborations)
  • Questions & answers
avatar-seller
CMPT225, Spring 2021

Final Exam

Name_________________________

SFU ID: |__|__|__|__|__|__|__|__|__|

Problem 1

Problem 2

Problem 3

Problem 4

TOTAL


Instructions:
1. You should write your solutions directly in this word file,
and submit it to Coursys. Submitting a pdf is also ok.

2. Submit your solutions to Coursys before April 20, 23:59.
No late submissions, no exceptions

3. Write your name and SFU ID on the top of this page.

4. This is an open book exam.
You may use textbooks, calculators, wiki, stack overflow, geeksforgeeks, etc.
If you do, specify the references in your solutions.

5. Discussions with other students are not allowed.
Posting questions online asking for solutions is not allowed.

6. The exam consists of four (4) problems. Each problem is worth 25 points.

7. Write your answers in the provided space.

8. You may use all classes in standard Java, and everything we have learned.

9. Explain all your answers.

10. Really, explain all your answers.

Good luck!
Problem 1 [25 points]



This study source was downloaded by 100000850872992 from CourseHero.com on 04-09-2023 03:16:50 GMT -05:00


https://www.coursehero.com/file/161942571/CMPT225-finaldocx/

, A. (15 points) In this question you need to design a data structure that supports
PriorityQueue with deletions. Specifically, you need to write the class
PriorityQueueWithDeletions. As a motivation you may think of a priority queue for a
printer that allows adding a document, removing a document in some order (e.g.
shorter documents are printed first), or a user can cancel the job. Specifically the class
needs to support the following operations:
The running time of each operation must be O(log(size of the queue)).
public class PriorityQueueWithDeletions<T extends Comparable<T>> {

public PriorityQueueWithDeletions() - creates an empty priority
queue

public Ticket add(T item) - adds a new element to the queue.
Returns a ticket that can be used to remove your item from the
queue.

public T removeHighestPriority() - removes the element with the
highest priority from the queue and
returns it.

public removeByTicket(Ticket t) - removes an element by ticket,
and returns the removed
element.

public int size() - returns the number of elements in the queue

public boolean isEmpty() - checks if the queue is empty

}


The running time of each operation must be O(log(n)), where n is the size of the
priority queue.

Explain your answer in detail. Define the class Ticket and explain how you use it.
Make sure Ticket does not allow the user to modify the queue adversarially.




This study source was downloaded by 100000850872992 from CourseHero.com on 04-09-2023 03:16:50 GMT -05:00


https://www.coursehero.com/file/161942571/CMPT225-finaldocx/

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller beckyfawcet. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $6.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

76658 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$6.49
  • (0)
  Add to cart