Lab06 Stack Queue
Lab06 Stack Queue
Lab 06
Stack & Queue
Cảm ơn thầy Trần Duy Quang đã cung cấp template cho môn học
1
Notes
Create a single solution/folder to store your source code in a week.
Then, create a project/sub-folder to store your source code of each assignment.
The source code in an assignment should have at least 3 files:
• A header file (.h): struct definition, function prototypes/definition.
• A source file (.cpp): function implementation.
• Another source file (.cpp): named YourID_Ex01.cpp, main function. Replace 01 by id of an
assignment.
Make sure your source code was built correctly. Use many test cases to check your code before
submitting to Moodle.
2
CS162 – Programming Techniques Lab06 – Stack & Queue
2
Content
In this lab, we will review the following topics:
• Stack, queue and their applications.
3
CS162 – Programming Techniques Lab06 – Stack & Queue
3
Assignments
A: YY: 01
H: YY: 01 (choose 1 in [3.1, 3.2], and 1 in [3.3, 3.4])
struct Stack{
int *data; // dynamic array
int top; // index of top element
int capacity; // size of stack
};
struct Node{
int data;
Node *next;
};
struct Stack{
4
CS162 – Programming Techniques Lab06 – Stack & Queue
Node *head;
int capacity;
};
struct Queue
{
int *data;
int in;
int out;
int capacity;
};
struct Queue{
Node *head;
Node *tail;
int capacity;
};
5
CS162 – Programming Techniques Lab06 – Stack & Queue