100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
cse 2050 exam 2 Questions with 100% Actual correct answers | verified | latest update | Graded A+ | Already Passed | Complete Solution $7.99   Add to cart

Exam (elaborations)

cse 2050 exam 2 Questions with 100% Actual correct answers | verified | latest update | Graded A+ | Already Passed | Complete Solution

 3 views  0 purchase
  • Course
  • Institution

cse 2050 exam 2 Questions with 100% Actual correct answers | verified | latest update | Graded A+ | Already Passed | Complete Solution

Preview 2 out of 7  pages

  • June 24, 2024
  • 7
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
avatar-seller
cse 2050 exam 2
recursion - ANS-technique of making a function fall itself, providing a way to break
complicated problems down into simple problems that are easier to solve

recursive function rules - ANS-1. there must be at least one base condition so that the
function eventually stops calling itself

2. the recursive step must make the function move towards the base case

function call stack - ANS-(often referred to just as the call stack or the stack) is
responsible for maintaining the local variables and parameters during function execution

calling a function pushes onto the stack, returning pops a frame off the stack

greedy algorithm - ANS-an algorithmic strategy that makes the best optimal choice at
each small stage with the goal of this eventually leading to a globally optimum solution

dynamic programming - ANS-storing previously calculated values to prevent repetitive
calculations and allow for quick retrievals as well as using smaller values to solve for
even larger ones

memoization - ANS-"top-down"
1. write the recursive function top-down
2. alter the function to check if we've already calculated the value
3. if so, use calculated value
4. if not, recursive call

pros of memoization - ANS-can be intuitive and memory saving, but has a larger
overhead because of recursion

tabulation - ANS-"bottom up"
start with solutions to the smallest problems and build solutions to the larger problems;
iterative solution

bubble sort - algorithm - ANS-def --sort(L):
has_swapped = True
while(has_swapped):
has_swapped = False

, for i in range(len(L)-1):
if L[i] > L[i+1]:
L[i], L[i+1] = L[i+1], L[i]
swaps += 1
has_swapped = True

if no elements swapped during the pass, can safely exit

insertion sort - algorithm - ANS-def --sort(L):
n = len(L)
i=0
while i < n:
j=n-i-1
while j < n - i - 1:
L[j], L[j+1] = L[j+1], L[j]
j += 1
i += 1

after iteration i, the last i elements are sorted; starts at position n-i-1 and goes to the end

selection sort - algorithm - ANS-def --sort(L):
n = len(L)
for i in range(n-1):
max_j = 0
for j in range(n-i):
if L[j] > L[max_j]:
max_j = j
if (n-i-1) != max_j:
L[n-i-1], L[max_j] = L[max_j], L[n-i-1]

binary search - ANS-a search algorithm that starts at the middle of a sorted set of
numbers and removes half of the data; this process repeats until the desired value is
found or all elements have been eliminated.

binary search - running time - ANS-asymptotic running time is o(log n)

tail recursion - ANS-a recursive function in which the recursive call is the last statement
that is executed by the function; nothing is left to execute after the recursion call

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 Hkane. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

73243 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

Recently viewed by you


$7.99
  • (0)
  Add to cart