100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
C949 TEST QUESTIONS AND ANSWERS 100% SOLVED $16.49   Add to cart

Exam (elaborations)

C949 TEST QUESTIONS AND ANSWERS 100% SOLVED

 8 views  0 purchase
  • Course
  • WGU C949
  • Institution
  • WGU C949

Exam of 64 pages for the course WGU C949 at WGU C949 (C949 TEST)

Preview 4 out of 64  pages

  • August 10, 2024
  • 64
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • WGU C949
  • WGU C949
avatar-seller
Dreamer252
C949 TEST

True - answerdef find(lst, item, low, high, indent):
"""
Finds index of string in list of strings, else -1.
Searches only the index range low to high
Note: Upper/Lower case characters matter
"""
print(indent, 'find() range', low, high)
range_size = (high - low) + 1
mid = (high + low) // 2
if item == lst[mid]: # Base case 1: Found at mid
print(indent, 'Found person.')
pos = mid
elif range_size == 1: # Base case 2: Not found
print(indent, 'Person not found.')
pos = 0
else: # Recursive search: Search lower or upper half
if item < lst[mid]: # Search lower half
print(indent, 'Searching lower half.')
pos = find(lst, item, low, mid, indent + ' ')
else: # Search upper half
print(indent, 'Searching upper half.')
pos = find(lst, item, mid+1, high, indent + ' ')
print(indent, 'Returning pos = %d.' % pos)
return pos
attendees = []
attendees.append('Adams, Mary')
attendees.append('Carver, Michael')
attendees.append('Domer, Hugo')
attendees.append('Fredericks, Carlo')
attendees.append('Li, Jie')
name = input("Enter person's name: Last, First: ")
pos = find(attendees, name, 0, len(attendees)-1, ' ')
if pos >= 0:
print('Found at position %d.' % pos)
else:
print( 'Not found.')

The above debug approach requires an extra parameter to be passed to indicate the
amount of indentation.

,True - answerdef find(lst, item, low, high, indent):
"""
Finds index of string in list of strings, else -1.
Searches only the index range low to high
Note: Upper/Lower case characters matter
"""
print(indent, 'find() range', low, high)
range_size = (high - low) + 1
mid = (high + low) // 2
if item == lst[mid]: # Base case 1: Found at mid
print(indent, 'Found person.')
pos = mid
elif range_size == 1: # Base case 2: Not found
print(indent, 'Person not found.')
pos = 0
else: # Recursive search: Search lower or upper half
if item < lst[mid]: # Search lower half
print(indent, 'Searching lower half.')
pos = find(lst, item, low, mid, indent + ' ')
else: # Search upper half
print(indent, 'Searching upper half.')
pos = find(lst, item, mid+1, high, indent + ' ')
print(indent, 'Returning pos = %d.' % pos)
return pos
attendees = []
attendees.append('Adams, Mary')
attendees.append('Carver, Michael')
attendees.append('Domer, Hugo')
attendees.append('Fredericks, Carlo')
attendees.append('Li, Jie')
name = input("Enter person's name: Last, First: ")
pos = find(attendees, name, 0, len(attendees)-1, ' ')
if pos >= 0:
print('Found at position %d.' % pos)
else:
print( 'Not found.')

Each recursive call should add a few spaces to the indent parameter.

False - answerdef find(lst, item, low, high, indent):
"""
Finds index of string in list of strings, else -1.
Searches only the index range low to high
Note: Upper/Lower case characters matter
"""
print(indent, 'find() range', low, high)

,range_size = (high - low) + 1
mid = (high + low) // 2
if item == lst[mid]: # Base case 1: Found at mid
print(indent, 'Found person.')
pos = mid
elif range_size == 1: # Base case 2: Not found
print(indent, 'Person not found.')
pos = 0
else: # Recursive search: Search lower or upper half
if item < lst[mid]: # Search lower half
print(indent, 'Searching lower half.')
pos = find(lst, item, low, mid, indent + ' ')
else: # Search upper half
print(indent, 'Searching upper half.')
pos = find(lst, item, mid+1, high, indent + ' ')
print(indent, 'Returning pos = %d.' % pos)
return pos
attendees = []
attendees.append('Adams, Mary')
attendees.append('Carver, Michael')
attendees.append('Domer, Hugo')
attendees.append('Fredericks, Carlo')
attendees.append('Li, Jie')
name = input("Enter person's name: Last, First: ")
pos = find(attendees, name, 0, len(attendees)-1, ' ')
if pos >= 0:
print('Found at position %d.' % pos)
else:
print( 'Not found.')

The function should remove a few spaces from the indent parameter before returning.

True - answerA recursive function with parameter n counts up from any negative
number to 0. An appropriate base case would be n == 0.

True - answerA recursive function can have two base cases, such as n == 0 returning 0,
and n == 1, returning 1.

False - answern factorial (n!) is commonly implemented as a recursive function due to
being easier to understand and executing faster than a loop implementation.

True - answerIn the code below, suppose str1 is a pointer or reference to a string. The
code only executes in constant time if the assignment copies the pointer/reference, and
not all the characters in the string.
srt2 = str1

, True - answerCertain hardware may execute division more slowly than multiplication,
but both may still be constant time operations.

False - answerThe hardware running the code is the only thing that affects what is and
what is not a constant time operation.

True - answerComputational complexity analysis allows the efficiency of algorithms to
be compared.

False - answerTwo different algorithms that produce the same result have the same
computational complexity.

False - answerRuntime and memory usage are the only two resources making up
computational complexity.

False - answerNearly every algorithm has a best-case time complexity when N = 0.

False - answerAn algorithm's best and worst case scenarios are always different.

listSize - answerGetEvent(list, listSize) {
i=0
evensList = Create new, empty list
while (i < listSize) {
if (list[i] % 2 == 0)
Add list[i] to evensList
i=i+1
}
return evensList
}

What is the maximum possible size of the returned list?

0 - answerGetEvent(list, listSize) {
i=0
evensList = Create new, empty list
while (i < listSize) {
if (list[i] % 2 == 0)
Add list[i] to evensList
i=i+1
}
return evensList
}

What is the minimum possible size of the returned list?

S(N) = N + k - answerGetEvent(list, listSize) {

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

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

81531 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
$16.49
  • (0)
  Add to cart