q1-s2008-sol

q1-s2008-sol - March 12, 2008 6.006 Spring 2008 Quiz 1...

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

View Full Document Right Arrow Icon
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 Ω Ω Ω
Background image of page 1

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

View Full DocumentRight Arrow Icon
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:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/20/2012 for the course CS 6.006 taught by Professor Erikdemaine during the Fall '08 term at MIT.

Page1 / 11

q1-s2008-sol - March 12, 2008 6.006 Spring 2008 Quiz 1...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online