Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help fix my code i cant get it to run correctly. ill lleave the code and error below # - - - - -
please help fix my code i cant get it to run correctly. ill lleave the code and error below # PROBLEM SARANGE
def sarangestart: int, end: int StaticArray:
Function that receives the two integers start and end and returns StaticArray
containing all consecutive integers start and end N complexity
arr StaticArrayend start
for i j in enumeraterangestart end :
arr.seti j
return arr
# PROBLEM ISSORTED
def issortedarr: StaticArray int:
Function receives StaticArray and returns integer returns array that describes
if array is sorted: if ascending, descending and otherwise
ascending True
descending True
for i in range arr.length:
if arr.geti arr.geti :
ascending False
if arr.geti arr.geti :
descending False
if not ascending and not descending:
return
return if ascending else
# PROBLEM REMOVEDUPLICATES
def removeduplicatesarr: StaticArray StaticArray:
Function receives a StaticArray already sorted, nondescending or nonascending
Returns a new static array with all duplicate values removed
unique StaticArray
unique.set arr.get
for i in range arr.length:
if arr.geti arr.geti:
unique.setuniquelength arr.geti
return unique
# PROBLEM COUNTSORT
def countsortarr: StaticArray StaticArray:
Function receives a StaticArray and returns a new StaticArray with same content
sorted in nonascending order using count sort algorithm
maxvalue arr.get
for i in range arr.length:
if arr.geti maxvalue:
maxvalue arr.geti
count maxvalue
for i in rangearrlength:
countarrgeti
for i in range maxvalue :
counti counti
sortedarray StaticArrayarrlength
for i in rangearrlength:
sortedarray.setcountarrgeti arr.geti
countarrgeti
return sortedarray
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started