set11_sol

set11_sol - CS112 Spring 2011: Problem Set 11 Graphs I - 1....

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

View Full Document Right Arrow Icon
CS112 Spring 2011: Problem Set 11 Graphs I ------------------------------------------------------------------------ 1. Suppose a weighted undirected graph has /n/ vertices and /e/ edges. The weights are all integers. Assume that the space needed to store an integer is the same as the space needed to store an object reference, both equal to one unit. /What is the minimum value of e/ for which the adjacency matrix representation would require less space than the adjacency linked lists representation? Ignore the space needed to store vertex labels. *SOLUTION* Space for adjacency matrix (AMAT) is /n^2/. Space for adjacency linked lists (ALL) is /n + 2*2e = n + 4e/. (Each node needs 2 units of space, and there are 2/e/ nodes.) The space required by AMAT and ALL is the same when /n^2 = n + 4e/, i.e. when /e = (n^2 - n)/4/. The minimum value of /e/ for which the adjacency matrix representation would require less space than the adjacency linked lists representation is one more than the /e/ above, which would be /(n^2 - n)/4+1/.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 11/01/2011 for the course 198 112 at Rutgers.

Page1 / 3

set11_sol - CS112 Spring 2011: Problem Set 11 Graphs I - 1....

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

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