Table of Contents

Chapter 2

2.1 Computational Tractability

Algorithm Goals

  1. Many algorithms are discrete: the goal is to efficiently find a solution that satisfies certain very clear conditions.
  2. Running Time
  3. Efficiency: amount of space (or memory)

Defining Efficiency

Worst-Case Running Times and Brute-Force Search

Polynomial Time

2.2 Asymptotic Order of Growth

Running Time: Coarser Level of Granularity

O, Ω, and Θ

Properties of Asymptotic Growth Rates

Asymptotic Bounds for Some Common Functions

Asymptotically speaking, exponential functions are all different. Logarithms grow more slowly than polynomials, and polynomials grow more slowly than exponentials.


Personal Thoughts

While this chapter dove into more of the complex details, it still was laid out in a way that was pretty easy to understand. 2.1 was definitely easier to understand than 2.2. Obviously there are a lot of notations that correspond to various functions, but I believe the overall concepts make sense. It would help to see applications of each of these bounds, which would also make this more interesting. Readability: 7 Interesting: 5

2.3 Implementing the Stable Matching Algorithm Using Lists & Arrays

Arrays and Lists

Arrays:

Linked List:

Doubly Linked List:

Implementing the Stable Matching Algorithm

Required Constant Time Actions

  1. Identify a free man
  2. For a man m, identify the highest-ranked woman to whom he has not yet proposed
  3. For a woman w, decide is she is currently engaged, and if so, identify her current partner
  4. For a woman w and two men m and m', decide who is preferred by w
  1. Identify a free man: use a linked list; take the first man on the list, delete him when engaged, potentially insert m' at the front of the list
  2. Identify the highest-ranked woman on a list: have an array Next that indicates the position of the next woman on his list for each man; initialization: Next[m] = 1; search: ManPref[m,Next[m]], increment value of Next[m] after proposal
  3. Identify Engaged Woman's Current Partner: have an array Current; Current[w] = man she is currently engaged to; initialization: Current[w] = null
  4. Identify Woman's Preference between m and m': use a 2D array Ranking consisting of [w,m] for each woman and her preferences. Compare values of Ranking[w,m] and Ranking[w,m'] in constant time.

Total Implementation Runtime: O(n2)


Personal Thoughts

This section was relatively easy to understand as it was mostly review from CSCI 112. The refresher on lists and arrays was helpful, and was useful to review before exploring the implementation of the Stable Matching Problem. Between class lecture and this textbook section, the implementation and the associated running time makes sense. Readability: 10 Interesting: 8

2.4 A Survey of Common Running Times

Two Kinds of Bounds:

Linear Time

Computing the Maximum

Merging Two Sorted Lists

O(n log n) Time

Common for any algorithm that splits input into two equal-sized parts, solves each part recursively, and then combines the two in linear time

Quadratic Time

Cubic Time

O(nk) Time

Beyond Polynomial Time

Sublinear Time


Personal Thoughts

This section was useful to read, as I sometimes struggle to identify situations where different running times apply. The more basic running times make sense, but I did struggle a little bit to understand the more complex running times (O(nk) time, sublinear time, etc.). This section will be good to look back upon when we get into later algorithms. Readability: 6 Interesting: 6

2.5 A More Complex Data Structure: Priority Queues

The Problem

A Data Structure for Implementing a Priority Queue

The Heap: balanced binary tree; root + nodes with up to two children; key of any element is at least as large as the key of the parent node

Implementing the Heap Operations

Implementing Priority Queues with Heaps


Personal Thoughts

This section was pretty straightforward and easy to follow. I think going over the concepts in class before reading this section of the textbook was helpful in clarifying things that maybe would have been otherwise confusing. I appreciated the summary of the operation run times as these can sometimes be difficult to recall. Readability: 9 Interesting: 6