{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

q1-s2008-sol

# q1-s2008-sol - 6.006 Spring 2008 Quiz 1 Solutions...

This preview shows pages 1–3. Sign up to view the full content.

Introduction to Algorithms March 12, 2008 Massachusetts Institute of Technology 6.006 Spring 2008 Professors Srini Devadas and Erik Demaine Quiz 1 Solutions Quiz 1 Solutions Problem 1. Asymptotic workout [15 points] For each function f ( n ) along the left side of the table, and for each function g ( n ) across the top, write O , Ω , or Θ in the appropriate space, depending on whether f ( n ) = O ( g ( n )) , f ( n ) = Ω( g ( n )) , or f ( n ) = Θ( g ( n )) . If more than one such relation holds between f ( n ) and g ( n ) , write only the strongest one. The first row is a demo solution for f ( n ) = n 2 . g ( n ) n n lg n n 2 n 2 Ω Ω Θ n 1 . 5 Ω Ω O 2 n Ω Ω Ω f ( n ) n lg n Ω O O n log 30 n Ω Θ O n 3 Ω Ω Ω

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6.006 Quiz 1 Solutions Name 2 Problem 2. Table of Speed [20 points] For each of the representations of a set of elements along the left side of the table, write down the asymptotic running time for each of the operations along the top. For hashing, give the expected running time assuming simple uniform hashing; for all other data structures, give the worst-case running time. Give tight asymptotic bounds using Θ notation. If we have not discussed how to perform a particular operation on a particular structure, answer for the most reasonable implemen- tation you can imagine. Operation Insert Extract-min Contains Minimum Θ(1) Θ( n ) Θ( n ) Θ( n ) Unsorted Insert at Check every Check every Check every linked list beginning element element element Θ( n ) Θ(1) Θ( n ) Θ(1) Sorted Walk down Remove first Walk down Return first linked list list element list element Data Θ(log n ) Θ(log n ) Θ( n ) Θ(1) Structure Min heap Seen in Seen in Check every Return first class class element element Θ(log n ) Θ( n ) Θ( n ) Θ( n ) Max heap Seen in Check every Check every Check every class element element element Hashsing with Θ(1) Θ( n ) Θ(1) Θ( n ) chainig and Seen in Check every Seen in Check every α = 1 class element class element Definitions of operations:
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 11

q1-s2008-sol - 6.006 Spring 2008 Quiz 1 Solutions...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online