TAILIEUCHUNG - Tut 3: Stack & Queue - ĐH Bách khoa TP.HCM

This Tut 3: Stack & Queue assumption using the stack and queue’s methods described below to solve all questions inside this tutorial. | Khoa Khoa học và Kỹ thuật máy tính Bộ môn Khoa học máy tính Tut 3: Stack& Queue Assumption: Using the stack and queue’s methods described below to solve all questions inside this tutorial. Stack: bool top(&data); // Get the value at top of stack, assign that value into //‘data’ and return true. If stack is empty, return false; void push(value); // Push a value on the top of stack. bool pop(&data); // Remove the object at the top of this stack, assign // value into ‘data’ variable, returns true if success and // false otherwise. bool isEmpty(); // Check if whether stack is empty. Return true if // stack is empty and return false otherwise. int size(); // Return the number of elements in stack. Queue: bool front(&data); // Get the value at front of queue, assign that value into //‘data’ and return true. If queue is empty, return false; void enqueue(value); // Add a value at rear of queue bool dequeue(&data); // Removes the object at the front of this queue, assign // value into ‘data’ variable, returns true if success and // false otherwise. bool isEmpty(); // Check if whether queue is empty. Return true if // queue is empty and return false otherwise. int size(); // Return the number of elements in queue. Question 1: a) Write code to construct a stack and a queue as follow 1 Khoa Khoa học và Kỹ thuật máy tính Bộ môn Khoa học máy tính b) Add code to change above stack and queue in (a) to: c) Add code to change above stack and queue in (b) to: (without using any primitive value) . push a primitive value Stack s; (1); Question 2: A Stacky program creates a stack and pushes following values orderly. 0 1 2 3 4 5 6 7 8 9 Stack s; Double a; (0); (1); (2); (3); (4); (5); (6); (7); (8); (9); Some pop and cout statements are inserted randomly after first push statement. 2 Khoa Khoa học và Kỹ thuật máy tính Bộ môn Khoa học máy tính For example: .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.