100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

C949 TEST QUESTIONS AND ANSWERS 100% SOLVED

Rating
-
Sold
-
Pages
64
Grade
A+
Uploaded on
10-08-2024
Written in
2024/2025

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

Institution
WGU C949
Course
WGU C949











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
WGU C949
Course
WGU C949

Document information

Uploaded on
August 10, 2024
Number of pages
64
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

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) {

Get to know the seller

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.
Dreamer252 NBursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
477
Member since
2 year
Number of followers
293
Documents
21305
Last sold
1 week ago

4.0

115 reviews

5
60
4
22
3
18
2
2
1
13

Recently viewed by you

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

Frequently asked questions