COIS 2020H Lecture 2: Stack class:

33 views7 pages

Document Summary

Int [ ] a | a= new int [6] If we need to insert a number in position 2, we move the number in the last position to the right. Move down when we insert [i ++] Sending the value when we retrieve: singly linked list. Currant. next = i ++ p. next = curr. next curr. next = p curr. next = curr. next. next: doubly linked list. If ( count < capacity && ( pos >= 0 && pos. For ( i = pos +1 ; i <= count -1; i++) Element [ i -1 ] = elemet [i] If ( pos >= 0 && pos <= count -1) The behaver is last in, first out. (loif) It"s also a generic class, you can put whatever you want in this class: array, capacity 6, element t [ , top index = -1 , that it"s mean empty.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents