Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Data Structures

# Data Structures

Ratings: (0)|Views: 778|Likes:

### Availability:

See more
See less

02/16/2013

pdf

text

original

Lecture Notes -- Data Structures
These lecture notes are designed for on-line reference and review.
Please do not print them on university computing facilities!!

Lecture 1 -- Data Structures and Programming

Lecture 2 -- Software Engineering and Top-Down Design

Lecture 3 -- Stacks and Queues

Lecture 4 -- Pointers and Dynamic Memory Allocation

Lecture 5 -- Linked Stacks and Queues

Lecture 6 -- Calculator Algorithms

Lecture 7 -- Linked Lists: Insertion and Deletion

Lecture 8 -- Do the Shuffle

Lecture 9 -- Recursive and Doubly Linked Lists

Lecture 10 -- Recursion and Backtracking

Lecture 11 -- Applications of Recursion

Lecture 12 -- Abstraction and Modules

Lecture 13 -- Object-Oriented Programming

Lecture 14 -- Simulations

Lecture 15 -- Asymptotics

Lecture 16 -- Introduction to Sorting

Lecture 17 -- Mergesort and Quicksort

Lecture 18 -- Heapsort and Priority Queues

Lecture 19 -- Sequential and Binary Search

Lecture 20 -- Access Formulas and Arrays

Lecture 21 -- Hashing

Lecture 22 -- Binary Search Trees

Lecture 23 -- Random Search Trees

Lecture 24 -- AVL TreesThese will not be covered in class, but theimplementation may be useful in doing the final program.

Lecture 25 -- Red-Black Trees

Lecture 26 -- Splay Trees

Lecture 27 -- Graphs

Data Structures and ProgrammingLecture 1
Steven S. Skiena

Why Data Structures?In my opinion, there are only three important
ideas
which must be mastered to write
interesting
programs.

Iteration
- Do, While, Repeat, If

Data Representation
- variables and pointers

Subprograms and Recursion
- modular design and abstractionAt this point, I expect that you have mastered about 1.5 of these 3.It is the purpose of
Computer Science II
to finish the job.Data types vs. Data StructuresA data
type
is a well-defined collection of data with a well-defined set of operations on it.A data
structure
is an actual implementation of a particular abstract data type.Example: The abstract data type Set has the operations EmptySet(S), Insert(x,S),Delete(x,S), Intersection(S1,S2), Union(S1,S2), MemberQ(x,S), EqualQ(S1,S2),SubsetQ(S1,S2).This semester, we will learn to implement such abstract data types by building datastructures from arrays, linked lists, etc.Modula-3 ProgrammingControl Structures: IF-THEN-ELSE, CASE-OFIteration Constructs: REPEAT-UNTIL (at least once), WHILE-DO (at least 0), FOR-DO(exactly
n
times).Elementary Data Types: INTEGER, REAL, BOOLEAN, CHAREnumerated Types: COINSIDE = {HEADS, TAIL, SIDE}Operations: +, -, <, >, #Elementary Data Structures

ArraysThese let you access lots of data fast. (good)You can have arrays of
any
other data type. (good)However, you cannot make arrays bigger if your program decides it needs more space.(bad)RecordsThese let you organize non-homogeneous data into logical packages to keepeverything together. (good)These packages do not include operations, just data fields (bad, which is why we needobjects)Records do not help you process distinct items in loops (bad, which is why arrays of records are used)SetsThese let you represent subsets of a set with such operations as intersection, union,and equivalence. (good)Built-in sets are limited to a certain small size. (bad, but we can build our own
set datatype
out of arrays to solve this problem if necessary)SubroutinesSubprograms allow us to break programs into units of reasonable size and complexity,allowing us to organize and manage even very long programs.This semester, you will first encounter programs big enough that
modularization
will be
necessary for survival
.Functions are subroutines which return values, instead of communicating by parameters.Abstract data types have each operation defined by a subroutine.Subroutines which call themselves are
recursive
. Recursion provides a very powerfulway to solve problems which takes some getting used to.Such standard data structures as linked lists and trees are inherently recursive datastructures.Parameter PassingThere are two mechanisms for passing data to a subprogram, depending upon whether thesubprogram has the power to alter the data it is given.