You are on page 1of 1

Revision Sheet (Stack, Queue, linked list)

1. Write a function that returns the first element entered to a stack.


2. Write a function that returns a copy from the last element in a stack.
3. Write a function to destroy a stack.
4. Write a function to copy a stack to another.
5. Write a function to return the size of a stack
6. Write a function to print on the screen the contents of a stack without changing the
stack.
7. Write a function that returns the last element in a queue.
8. Write a function to return the size of a queue
9. We (as a user for Queue ADT) have two filled queues; the first queue holds section code
while the other holds group code (where number of groups inside the section is
maximum 10). Merge those numbers (section code*10+group code) in a newly created
queue.
10. We (as a user for StackADT) have a stack holding group_ids. Each group_id consists of
two parts section code and group code within his section. Number of groups inside the
section is maximum 10. section_code=group_id/10, group_code=group_id%10.
Construct two stacks; one stack holds section codes while the other holds group codes.
11. Write the function void JoinList(List *pl1, List *pl2) that copies all entries from pl1 onto
the end of pl2.
12. It is required to have a fixed size structure Doubly_Ended that allows adding elements
from both ends; every end is viewed as a separate stack. In such a structure, the
maximum size of each stack is the size of the whole structure, and the size of the whole
structure is 20 elements. However, there is another restriction, i.e., the total size of the
two stacks cannot exceed the size of the whole structure.

(a) Write the definition of this structure (twice, array based and linked)
(b) Only for linked implementation, write the following basic functions for this structure:
Create, PushBottom that pushes from the logical lower end of the structure, PushUp
that pushes from the logical upper end of the structure, StackSize, StackEmpty,
StackFull, and DestroyStack.

Using the Doubly_Ended ADT, write a C program that allows users to:

(c) Store a set of integers into a Doubly_Ended ADT by entering the even numbers from
one end and the odd numbers from the other.
(d) Output the stored even numbers followed by odd numbers onto the screen.

Front 537428 Rear

Doubly_Ended ADT

You might also like