100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten
logo-home
cse 2050 exam 2 Questions with 100% Actual correct answers | verified | latest update | Graded A+ | Already Passed | Complete Solution $7.99
In winkelwagen

Tentamen (uitwerkingen)

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

 0 keer verkocht
  • Vak
  • Instelling

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

Voorbeeld 2 van de 7  pagina's

  • 24 juni 2024
  • 7
  • 2023/2024
  • Tentamen (uitwerkingen)
  • Vragen en antwoorden
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

Dit zijn jouw voordelen als je samenvattingen koopt bij Stuvia:

Bewezen kwaliteit door reviews

Bewezen kwaliteit door reviews

Studenten hebben al meer dan 850.000 samenvattingen beoordeeld. Zo weet jij zeker dat je de beste keuze maakt!

In een paar klikken geregeld

In een paar klikken geregeld

Geen gedoe — betaal gewoon eenmalig met iDeal, creditcard of je Stuvia-tegoed en je bent klaar. Geen abonnement nodig.

Direct to-the-point

Direct to-the-point

Studenten maken samenvattingen voor studenten. Dat betekent: actuele inhoud waar jij écht wat aan hebt. Geen overbodige details!

Veelgestelde vragen

Wat krijg ik als ik dit document koop?

Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.

Tevredenheidsgarantie: hoe werkt dat?

Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.

Van wie koop ik deze samenvatting?

Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper DoctorHkane. Stuvia faciliteert de betaling aan de verkoper.

Zit ik meteen vast aan een abonnement?

Nee, je koopt alleen deze samenvatting voor $7.99. Je zit daarna nergens aan vast.

Is Stuvia te vertrouwen?

4,6 sterren op Google & Trustpilot (+1000 reviews)

Afgelopen 30 dagen zijn er 64302 samenvattingen verkocht

Opgericht in 2010, al 15 jaar dé plek om samenvattingen te kopen

Begin nu gratis

Laatst bekeken door jou


$7.99
  • (0)
In winkelwagen
Toegevoegd