Algorithms and OOD (CSC 207 2014S) : Outlines

# Outline 33: An Introduction to Linear Structures

Held: Monday, 31 March 2014

Summary

We consider a general class of collections called "linear structures". We explore one kind of linear structure, the stack, in a bit more depth.

Related Pages

Overview

• Linear structures.
• Stacks.
• An application of stacks: Matching parens.

• Today's writeup: Exercise 4.
• Welcome to today's prospective.
• I will reserve time at the start of class for questions on the exam.
• I am returning the makeups for exam 1.
• 8 of you had no change. Many of your average functions still had bugs, many of your replacement functions were still O(n^2).
• Review session Tuesday night (I think)
• CS study break tonight (I think)
• Consider running for the SEPC
• Get ready to vote on T-Shirts (the Curried Lamb-Duh T-shirt is clearly the best)
• Extra credit:
• Convocation, Wednesday, noon: Elizabeth Colbert (the Sixth Extinction?)
• CS extras Thursday: ???
• CS table Friday: TBD

## Linear Structures

• Simple collections.
• Two basic operations: `put` and `get`.
• Sam thinks of linear structures as a magic box. You give the box a policy for returning values and it folows that policy when you get something.

## Stacks

• Linear structures with a "last in, first out" policy.
• Terminology: `put` is called `push`; `get` is called `pop`.
• Can be implemented with arrays or linked structures.

## Lab

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit `http://creativecommons.org/licenses/by/3.0/` or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.