DATA ANALYSIS > MARK SCHEME > University of Manitoba COMP 3170, Winter 2018 Assignment 4 Solutions (All)

University of Manitoba COMP 3170, Winter 2018 Assignment 4 Solutions

Document Content and Description Below

University of Manitoba COMP 3170, Winter 2018 Assignment 4 Due Date: March 27, at 8pm “The natural flights of the human mind are not from pleasure to pleasure, but from hope to hope.” Samuel ... Johnson All problems are written problems; submit your solutions electronically via Crowdmark. Please read http://www.cs.umanitoba.ca/~kamalis/winter20/comp3170/course-info. pdf for guidelines on academic integrity. Problem 1 Amortized Analysis [10 marks] In the class, we saw a special type of stacks in which each operation involves popping n ≥ 0 items followed by pushing exactly one item. Consider a variant in which each operation involves popping one item followed by pushing n ≥ 0 items. Assume the stack is implemented using an array of fixed size C and the number of items in the stack is never more than C. Use the potential function method to show the amortized cost of each operation is at most 2. Define the potential to be the number of empty cells in the array, that is, if x is the number of items in the stack, the potential is C −x. Given an operation involving n pushes, the actual cost is n + 1; for each push, the potential is decreased by 1 unit (one less empty space). So, the difference in potential will be −n for pushed items and +1 for the pop, i.e., a total difference of −n+1 for the potential. The amortized cost will be (n+1)+ (−n+1) = 2. You get 5 marks for the right potential function and 5 marks for finding the right amortized cost. You get the full mark as long as you show the amortized cost is constant via a potential function argument. Problem 2 Union by Weight [10 marks] In this problem, we would like to show the amortized time of a union operation when unionby-weight on linked-lists is used is Ω(log n). For that, we nee [Show More]

Last updated: 1 year ago

Preview 1 out of 5 pages

Add to cart

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Add to cart

Instant download

We Accept:

We Accept

Reviews( 0 )

$5.00

Add to cart

We Accept:

We Accept

Instant download

Can't find what you want? Try our AI powered Search

OR

REQUEST DOCUMENT
29
0

Document information


Connected school, study & course


About the document


Uploaded On

Nov 09, 2022

Number of pages

5

Written in

Seller


seller-icon
Browsegrades

Member since 2 years

0 Documents Sold


Additional information

This document has been written for:

Uploaded

Nov 09, 2022

Downloads

 0

Views

 29

Document Keyword Tags

What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·