Lecture5-2 - DataStructures CSCI 132, Spring 2012 Lecture 5...

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

View Full Document Right Arrow Icon
1 Data Structures   CSCI 132, Spring 2012 Lecture 5 Stacks
Background image of page 1

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

View Full DocumentRight Arrow Icon
int Life ::initialize( ) { int row, col; for (row = 1; row <= maxrow; row++) { for (col = 1; col <= maxcol; col++) { grid[row][col] = 0; } //end inner for loop } //end outer for loop cout << "List the coordinates for the living cells." << endl; cout << "Terminate the list with the pair -1 -1 " << endl; cin >> row >> col; while (row != -1 || col != -1) { grid[row][col] = 1; } else { cout << "Column " << col << " is out of range." << endl; } // end inner if-else } else { cout << "Row " << row << " is out of range." << endl; } //end outer if - else cin >> row >> col; } //end while loop } //end initialize()
Background image of page 2
3 Order of Development 1. initialize( ) 2. print( ) 3. count_neighbors( ) 4. update( )
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Lists A list is an abstract data type consisting of an ordered group of items. A list is dynamic. Its length can vary. Items can be added to or deleted from the list There are many ways of implementing a list. For example: An array Linked lists
Background image of page 4
Arrays Arrays in C++ have fixed length. Arrays can be used to implement lists.
Background image of page 5

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

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

This document was uploaded on 03/09/2012.

Page1 / 22

Lecture5-2 - DataStructures CSCI 132, Spring 2012 Lecture 5...

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

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