Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Name: # OSU Email: # Course: CS 2 6 1 - Data Structures # Assignment: # Due Date: # Description: import random from static

# Name:
# OSU Email:
# Course: CS261- Data Structures
# Assignment:
# Due Date:
# Description:
import random
from static_array import *
# ------------------- PROBLEM 1- MIN_MAX -----------------------------------
def min_max(arr: StaticArray)-> tuple[int, int]:
"""
TODO: Write this implementation
"""
pass
# ------------------- PROBLEM 2- FIZZ_BUZZ ---------------------------------
def fizz_buzz(arr: StaticArray)-> StaticArray:
"""
TODO: Write this implementation
"""
pass
# ------------------- PROBLEM 3- REVERSE -----------------------------------
def reverse(arr: StaticArray)-> None:
"""
TODO: Write this implementation
"""
pass
# ------------------- PROBLEM 4- ROTATE ------------------------------------
def rotate(arr: StaticArray, steps: int)-> StaticArray:
"""
TODO: Write this implementation
"""
pass
# ------------------- PROBLEM 5- SA_RANGE ----------------------------------
def sa_range(start: int, end: int)-> StaticArray:
"""
TODO: Write this implementation
"""
pass
# ------------------- PROBLEM 6- IS_SORTED ---------------------------------
def is_sorted(arr: StaticArray)-> int:
"""
TODO: Write this implementation
"""
pass
# ------------------- PROBLEM 7- FIND_MODE -----------------------------------
def find_mode(arr: StaticArray)-> tuple[object, int]:
"""
TODO: Write this implementation
"""
pass
# ------------------- PROBLEM 8- REMOVE_DUPLICATES -------------------------
def remove_duplicates(arr: StaticArray)-> StaticArray:
"""
TODO: Write this implementation
"""
pass
# ------------------- PROBLEM 9- COUNT_SORT --------------------------------
def count_sort(arr: StaticArray)-> StaticArray:
"""
TODO: Write this implementation
"""
pass
# ------------------- PROBLEM 10- SORTED SQUARES ---------------------------
def sorted_squares(arr: StaticArray)-> StaticArray:
"""
TODO: Write this implementation
"""
pass
# ------------------- BASIC TESTING -----------------------------------------
if __name__=="__main__":
print('
# min_max example 1')
arr = StaticArray(5)
for i, value in enumerate([7,8,6,-5,4]):
arr[i]= value
print(arr)
result = min_max(arr)
if result:
print(f"Min: {result[0]: 3}, Max: {result[1]}")
else:
print("min_max() not yet implemented")
print('
# min_max example 2')
arr = StaticArray(1)
arr[0]=100
print(arr)
result = min_max(arr)
if result:
print(f"Min: {result[0]}, Max: {result[1]}")
else:
print("min_max() not yet implemented")
print('
# min_max example 3')
test_cases =(
[3,3,3],
[-10,-30,-5,0,-10],
[25,50,0,10],
)
for case in test_cases:
arr = StaticArray(len(case))
for i, value in enumerate(case):
arr[i]= value
print(arr)
result = min_max(arr)
if result:
print(f"Min: {result[0]: 3}, Max: {result[1]}")
else:
print("min_max() not yet implemented")
print('
# fizz_buzz example 1')
source =[_ for _ in range(-5,20,4)]
arr = StaticArray(len(source))
for i, value in enumerate(source):
arr[i]= value
print(fizz_buzz(arr))
print(arr)
print('
# reverse example 1')
source =[_ for _ in range(-20,20,7)]
arr = StaticArray(len(source))
for i, value in enumerate(source):
arr.set(i, value)
print(arr)
reverse(arr)
print(arr)
reverse(arr)
print(arr)
print('
# rotate example 1')
source =[_ for _ in range(-20,20,7)]
arr = StaticArray(len(source))
for i, value in enumerate(source):
arr.set(i, value)
print(arr)
for steps in [1,2,0,-1,-2,28,-100,2**28,-2**31]:
space ="" if steps >=0 else "

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

7. Where Do We Begin?

Answered: 1 week ago