The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
Exercises positions, while has been shifted k=4 positions. ❍ Suppose you know what k is. Give an O(1) algorithm to find the largest number in A. ❍ Suppose you do not know what k is. Give an algorithm to find the largest number in A. For partial credit, you may give an O(n) algorithm. 12. (*) Suppose that you are given a sorted sequence of distinct integers . Give an algorithm to determine whether there exists an index i such at . For example, in , . In , there is no such i. Next: Implementation Challenges Up: Breaking Problems Down Previous: Square and Other Roots Algorithms Mon Jun 2 23:33:50 EDT 1997 file:///E|/BOOK/BOOK2/NODE57.HTM (4 of 4) [19/1/2003 1:29:01]
The Friendship Graph Next: Data Structures for Graphs Up: Graph Algorithms Previous: Graph Algorithms The Friendship Graph Figure: A portion of the friendship graph To demonstrate the importance of proper modeling, let us consider a graph where the vertices are people, and there is an edge between two people if and only if they are friends. This graph is well-defined on any set of people, be they the people in your neighborhood, at your school or place of business, or even the entire world. There are many interesting aspects of people that are best understood as properties of this friendship graph. We use this opportunity to define important graph theory terminology. ``Talking the talk'' proves to be an important part of ``walking the walk''. ● If I am your friend, does that mean you are my friend? A graph is undirected if edge (x,y) always implies (y,x). Otherwise, the graph is said to be directed. The ``heard-of'' graph is directed, since many famous people who I have heard of have never heard of me! The ``had-sex-with'' graph is presumably undirected, since the critical operation always requires a partner. I'd like to think that the ``friendship'' graph is always an undirected graph. ● Am I my own friend? An edge of the form (x,x) is said to be a loop. If x was y's friend several times over, we can model this relationship using multiedges, multiple edges between the same pair of vertices. A graph is said to be simple if it contains no loops and no multiple edges. Simple graphs really are often simpler to work with in practice. Therefore, we might be better off if no one was their own friend. ● How close a friend are you? A graph is said to be weighted if each edge has an associated numerical attribute. We could model file:///E|/BOOK/BOOK2/NODE60.HTM (1 of 3) [19/1/2003 1:29:02]
- Page 167 and 168: War Story: Mystery of the Pyramids
- Page 169 and 170: War Story: String 'em Up We were co
- Page 171 and 172: War Story: String 'em Up Figure: Su
- Page 173 and 174: Exercises Next: Implementation Chal
- Page 175 and 176: Exercises used to select the pivot.
- Page 177 and 178: Dynamic Programming Next: Fibonacci
- Page 179 and 180: Fibonacci numbers Next: The Partiti
- Page 181 and 182: Fibonacci numbers Next: The Partiti
- Page 183 and 184: The Partition Problem . What is the
- Page 185 and 186: The Partition Problem Figure: Dynam
- Page 187 and 188: Approximate String Matching Next: L
- Page 189 and 190: Approximate String Matching The val
- Page 191 and 192: Longest Increasing Sequence Will th
- Page 193 and 194: Minimum Weight Triangulation Next:
- Page 195 and 196: Limitations of Dynamic Programming
- Page 197 and 198: War Story: Evolution of the Lobster
- Page 199 and 200: War Story: Evolution of the Lobster
- Page 201 and 202: War Story: What's Past is Prolog Ne
- Page 203 and 204: War Story: What's Past is Prolog th
- Page 205 and 206: War Story: Text Compression for Bar
- Page 207 and 208: War Story: Text Compression for Bar
- Page 209 and 210: Divide and Conquer Next: Fast Expon
- Page 211 and 212: Fast Exponentiation Next: Binary Se
- Page 213 and 214: Binary Search Next: Square and Othe
- Page 215 and 216: Exercises Next: Implementation Chal
- Page 217: Exercises whose denominations are ,
- Page 221 and 222: The Friendship Graph friendship gra
- Page 223 and 224: Data Structures for Graphs linked t
- Page 225 and 226: War Story: Getting the Graph ``Well
- Page 227 and 228: Traversing a Graph Next: Breadth-Fi
- Page 229 and 230: Breadth-First Search Next: Depth-Fi
- Page 231 and 232: Depth-First Search Next: Applicatio
- Page 233 and 234: Depth-First Search Next: Applicatio
- Page 235 and 236: Connected Components Next: Tree and
- Page 237 and 238: Two-Coloring Graphs Next: Topologic
- Page 239 and 240: Topological Sorting Next: Articulat
- Page 241 and 242: Modeling Graph Problems Next: Minim
- Page 243 and 244: Modeling Graph Problems good line s
- Page 245 and 246: Minimum Spanning Trees ● Prim's A
- Page 247 and 248: Prim's Algorithm inserted edge (x,y
- Page 249 and 250: Kruskal's Algorithm a tree of weigh
- Page 251 and 252: Dijkstra's Algorithm Next: All-Pair
- Page 253 and 254: All-Pairs Shortest Path Next: War S
- Page 255 and 256: War Story: Nothing but Nets Next: W
- Page 257 and 258: War Story: Nothing but Nets ``You a
- Page 259 and 260: War Story: Dialing for Documents Ne
- Page 261 and 262: War Story: Dialing for Documents If
- Page 263 and 264: War Story: Dialing for Documents CO
- Page 265 and 266: Exercises Next: Implementation Chal
- Page 267 and 268: Exercises Prove the statement or gi
<strong>The</strong> Friendship Graph<br />
Next: Data Structures for Graphs Up: Graph <strong>Algorithm</strong>s Previous: Graph <strong>Algorithm</strong>s<br />
<strong>The</strong> Friendship Graph<br />
Figure: A portion of the friendship graph<br />
To demonstrate the importance of proper modeling, let us consider a graph where the vertices are people,<br />
and there is an edge between two people if and only if they are friends. This graph is well-defined on any<br />
set of people, be they the people in your neighborhood, at your school or place of business, or even the<br />
entire world. <strong>The</strong>re are many interesting aspects of people that are best understood as properties of this<br />
friendship graph.<br />
We use this opportunity to define important graph theory terminology. ``Talking the talk'' proves to be an<br />
important part of ``walking the walk''.<br />
● If I am your friend, does that mean you are my friend?<br />
A graph is undirected if edge (x,y) always implies (y,x). Otherwise, the graph is said to be<br />
directed. <strong>The</strong> ``heard-of'' graph is directed, since many famous people who I have heard of have<br />
never heard of me! <strong>The</strong> ``had-sex-with'' graph is presumably undirected, since the critical<br />
operation always requires a partner. I'd like to think that the ``friendship'' graph is always an<br />
undirected graph.<br />
● Am I my own friend?<br />
An edge of the form (x,x) is said to be a loop. If x was y's friend several times over, we can model<br />
this relationship using multiedges, multiple edges between the same pair of vertices. A graph is<br />
said to be simple if it contains no loops and no multiple edges. Simple graphs really are often<br />
simpler to work with in practice. <strong>The</strong>refore, we might be better off if no one was their own friend.<br />
● How close a friend are you?<br />
A graph is said to be weighted if each edge has an associated numerical attribute. We could model<br />
file:///E|/BOOK/BOOK2/NODE60.HTM (1 of 3) [19/1/2003 1:29:02]