100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSE 2221 FINAL EXAM 2024 QUESTIONS AND ANSWERS $12.99   Add to cart

Exam (elaborations)

CSE 2221 FINAL EXAM 2024 QUESTIONS AND ANSWERS

 8 views  0 purchase
  • Course
  • CSE 2221
  • Institution
  • CSE 2221

CSE 2221 FINAL EXAM 2024 QUESTIONS AND ANSWERS

Preview 3 out of 17  pages

  • September 7, 2024
  • 17
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • CSE 2221
  • CSE 2221
avatar-seller
Teacher101
CSE 2221 FINAL EXAM

What are the three methods of the Stack Interface? - ANSWERS-top

replaceTop

flip



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



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



What does the Stack method void push(T x) do? - ANSWERS-adds x to the top (left
end) of this

aliases reference x

updates this

ensures

this = <x> * #this



Why is the container class called Stack? - ANSWERS-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 - ANSWERS-last in first out



How is a Stack different than the queue? - ANSWERS-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? - ANSWERS-push

pop

length




What does the stack method T pop() do? - ANSWERS-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? - ANSWERS-Reports the length of
this

ensures

length = |this|

, What does the stack method T top() do? - ANSWERS-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? - ANSWERS-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|)



What does the stack method void flip() do? - ANSWERS-reverses ("flips") this

updates this

ensures

this = rev(#this)

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Teacher101. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75632 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$12.99
  • (0)
  Add to cart