Presentation is loading. Please wait.

Presentation is loading. Please wait.

Midterm Review Linear list Stack queue. What is a data structure What is an abstract data type.

Similar presentations


Presentation on theme: "Midterm Review Linear list Stack queue. What is a data structure What is an abstract data type."— Presentation transcript:

1 Midterm Review Linear list Stack queue

2 What is a data structure What is an abstract data type

3 Linear list Array representation L=(a,b,c) – Arraylength = 5 – Draw a figure showing the contents of the array element and value of listSize after the operation sequences

4 Linear list Linked representation L=(a,b,c) – Draw a figure showing the contents of the chain element and value of listSize after the operation sequences

5

6

7

8 Stack draw figure to show the stack configuration after above operation sequence.

9 Queue draw figure to show the queue configuration after above operation sequence.

10 deque

11 Read sample programs http://www.cplusplus.com/reference/stl/ Vector List Stack Queue Deque

12 Write coding idea In a circular shift operation, the elements of a linear list are rotated clockwise by a given amount. For example, when the elements of x = [0,1,2,3,4] are shifted circularly by 2, the result is x=[2,3,4,0,1].

13 Applications Rat in a Maze Wire Routing

14 Homework 2.2 // Recursive Towers of Hanoi #include using namespace std; void towersOfHanoi(int n, int x, int y, int z) {// Move the top n disks from tower x to tower y. // Use tower z for intermediate storage. if (n > 0) { towersOfHanoi(n-1, x, z, y); cout << "Move top disk from tower " << x << " to top of tower " << y << endl; towersOfHanoi(n-1, z, y, x); } void main(void) { cout << "Moves for a three disk problem are" << endl; towersOfHanoi(3,1,2,3); }

15 Homework 3.1 Make a 2d array for representing the maze – Make2darray.h Identify the position – Position.h

16 Global variables // global variables int** grid; // 2D array int size; // number of rows and columns in the grid int pathLength; // length of shortest wire path Queue q; // queue of unexpanded reached positions position start, // one end point of wire finish; // other end point position* path; // the shortest path

17 int main() { inputData(); if (findPath()) outputPath(); else cout << "There is no wire path" << endl; return 0; }

18 Sample codes On course notes page!


Download ppt "Midterm Review Linear list Stack queue. What is a data structure What is an abstract data type."

Similar presentations


Ads by Google