0% found this document useful (0 votes)
13 views2 pages

Stack Implementation Program Guide

The document outlines instructions for creating a Stack evidence document, including the requirement to include personal information on each page. It details the programming tasks related to implementing a stack using a 1D array, including writing code for the Stack, Push(), and Pop() functions, as well as adding specific data to the stack and executing the Pop() function multiple times. Additionally, it instructs the user to take a screenshot of the test program and include it in the evidence document.

Uploaded by

ngkhoinguyen3006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Stack Implementation Program Guide

The document outlines instructions for creating a Stack evidence document, including the requirement to include personal information on each page. It details the programming tasks related to implementing a stack using a 1D array, including writing code for the Stack, Push(), and Pop() functions, as well as adding specific data to the stack and executing the Pop() function multiple times. Additionally, it instructs the user to take a screenshot of the test program and include it in the evidence document.

Uploaded by

ngkhoinguyen3006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Open the document Stack Evidence.

docx
Make sure that your name, centre number and candidate number will appear on every page of
this document. This document must contain your answers to each question.
Save this evidence document in your work area as:
evidence_ followed by your centre number_candidate number, for example:
evidence_zz999_9999
A class declaration can be used to declare a record.
If the programming language used does not support arrays, a list can be used instead.

1. A 1D array, Stack, is used to implement a stack. The array of 8 elements is declared as


a string data type.
The global variable TopOfStack stores the index of the first node in the list.
a) Write the program code for Stack and TopOfStack.
Save your program as Question 1.

Copy and paste the program code into part 1(a) in the evidence document.
[2 marks]

b) The procedure Push() takes as a parameter value to be added into the Stack.
The procedure tries to add the parameter value into the stack and displays an
appropriate message if the parameter value has been added onto the Stack or
not.
Write the program code for Push() procedure.
Save your program as Question 1.

Copy and paste the program code into part 1(b) in the evidence document.
[4 marks]

c) The function Pop () takes the data from top of the stack to be removed from
Stack.
The function set the value to <blank> "" and moves the TopOfStack location
down a notch.
The function returns the name of the popped item, or -1 if the stack is empty.
Write the program code for Pop () function.
Save your program.

Copy and paste the program code into part 1(c) in the evidence document.
[3 marks]
d) From the main program, use the Push () function to add the following data into
the Stack.
Alabaster (top of stack)
Amaranth Green
Biscotti
Cobalt
Lilac
Garnet
Onyx
Titan
Vermilion (bottom of stack)

Save your program.

Copy and paste the program code into part 1(d) in the evidence document.
[1 mark]
e) execute the Pop() function ten times (10) and display each item popped out of
the Stack.

Save your program.

Copy and paste the program code into part 1(e) in the evidence document.
[3 marks]
f) Take a screen shot of your test program.

Copy and paste the screenshot into part 1(f) in the evidence document.

[2 marks]

You might also like