Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

Practice Final Simon Fraser University CMPT 225

Beoordeling
-
Verkocht
-
Pagina's
8
Cijfer
A+
Geüpload op
09-04-2023
Geschreven in
2022/2023

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 the nodes of L 00, in the same order. What is the running time of your algorithm? 2. Suppose that a binary tree T is rooted at r and has n nodes. Provide a recursive or an iterative algorithm (your choice) for computing the number of descendants of all the nodes that runs in O(n) time.

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

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/

Geschreven voor

Vak

Documentinformatie

Geüpload op
9 april 2023
Aantal pagina's
8
Geschreven in
2022/2023
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$6.99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
beckyfawcet Rasmussen College
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
112
Lid sinds
4 jaar
Aantal volgers
19
Documenten
599
Laatst verkocht
1 dag geleden
GradesBooster

Verified eBooks available for a Quick and Easy Download at Affordable rates I OFFER: -Study Guides -eBooks -ATI Test Prep, Assignments -WGU Papers, \"Task\" Assignments (Complete RN BSN Curriculum), Rubric &amp; Task Info for Each Course -HCI College Nursing Associates Program -NCLEX Prep *ALL WORK HAS PASSED WITHOUT NEEDING REVISIONS AND BY THE RUBRIC.

4.2

26 beoordelingen

5
18
4
2
3
2
2
1
1
3

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen