top of page

Exercises (Practice) for stack

  • Karla G
  • 28 mar 2015
  • 1 Min. de lectura

Questions:

1.- Which of the options below, are stacks?

  • Pile of boxes

  • Music Reproduction (playlist)

  • The sheets in a printer

  • Waiting for your turn in a game

  • Taking books from a pile

  • Using Ctrl+Z in a Word document

2.- What kind of order does the Stack respects?

  • FILO (First in, Last Out)

  • FIFO (First in, First Out)

3.- Write the pseudocode of a function that returns TRUE when the stack has an empty space where you can still push an element.

Answers:

1.- Pile of boxes, sheets in a printer, taking books from a pile, using Ctrl+Z in a word document.

Why? Because they are all piles where the first uotput, will always be the last element that entered to the pile. In order to carry boxes, you have to take the ones at the top first. When printing, the first page printed will be the last page of the document. Using Ctrl+Z will erase your last movement.

2.- FILO. First in, last out. As it was commented at the previous answer.

3.-

Empty(){

boolean space=FALSE;

for(int i=0; i<STACK.SIZE; i++){

if(Stack[i].isNotEmpty){

space=space;

}

else{

space=TRUE;

}

}

}

 
 
 

Comentarios


 THE ARTIFACT MANIFAST: 

 

This is a great space to write long text about your company and your services. You can use this space to go into a little more detail about your company. Talk about your team and what services you provide. Tell your visitors the story of how you came up with the idea for your business and what makes you different from your competitors. Make your company stand out and show your visitors who you are. Tip: Add your own image by double clicking the image and clicking Change Image.

 UPCOMING EVENTS: 

 

10/31/23:  Scandinavian Art Show

 

11/6/23:  Video Art Around The World

 

11/29/23:  Lecture: History of Art

 

12/1/23:  Installations 2023 Indie Film Festival

 FOLLOW THE ARTIFACT: 
  • Facebook B&W
  • Twitter B&W
  • Instagram B&W
 RECENT POSTS: 
 SEARCH BY TAGS: 

© 2023 by Karla Lugo. Proudly created with Wix.com

bottom of page