Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 13 pages
Exam (elaborations)

CSE 2221 Final Exam |Questions with Correct Answers| Verified| Latest update 2025/2026

Document preview thumbnail
Preview 2 out of 13 pages

CSE 2221 Final Exam |Questions with Correct Answers| Verified| Latest update 2025/2026

Content preview

CSE 2221 Final Exam |Questions with Correct Answers| Verified|
Latest update 2025/2026
Why is the container class called Stack? - Answer✔✔It follows the same sort of organization
and manipulation type that a stack in the program execution would perform LIFO (last-in-
first-out)



LIFO - Answer✔✔last in first out



How is a Stack different than the queue? - Answer✔✔it is like a "dual" A queue is first in first
out, while stack is last in first out



What are the three methods of StackKernel? - Answer✔✔push
pop
length



What are the three methods of the Stack Interface? - Answer✔✔top
replaceTop
flip



What mathematical model is Stack modeled by? - Answer✔✔Modeled by mathematical
string of T



How many constructors for Stack? - Answer✔✔only 1, which is empty, creates an empty
stack



What does the Stack method void push(T x) do? - Answer✔✔adds x to the top (left end) of
this
aliases reference x
updates this
ensures
this = <x> * #this

, What does the stack method T pop() do? - Answer✔✔Removes and retursn the entry at the
top (left end of this)
updates this
requires this /= <>
ensures
#this = <pop> * this



What does the stack method int length() do? - Answer✔✔Reports the length of this
ensures
length = |this|



What does the stack method T top() do? - Answer✔✔Returns the entry at the top (left end)
of this
Aliases: reference returned by top
requires:
this /= <>
ensures
<top> is prefix of this



What does the stack method T replaceTop(T x) do? - Answer✔✔replaces top of this with x,
and returns the old top
aliases reference x
updates this
requires
this /= <>
ensures:
<replaceTop> is prefix of #this and
this = <x> * #this[1, |#this|)

Document information

Uploaded on
October 5, 2025
Number of pages
13
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ExamsCentre
3.7
(3)
Sold
13
Followers
0
Items
1709
Last sold
3 months ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions