# GADPVRRR **Handle:** @gadpvrrr ## Stats - **Projects:** 16 - **Components:** 0 - **Followers:** 0 - **Following:** 0 ## More - [Starred Projects](https://www.flux.ai/gadpvrrr/starred.md) ## Projects (Page 1 of 1, 7 total) - [Frantic Plum Pip boy](https://www.flux.ai/gadpvrrr/frantic-plum-pip-boy.md) - como puedo corregir este codigo para que funcione en flux.io import time import random import matplotlib.pyplot as plt import io import base64 from fluxio import Flow flow = Flow() @flow.task def linear_search(arr, target): for i in range(len(arr)): if arr[i] == target: return i return -1 @flow.task def binary_search(arr, target): low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] < target: low = mid + 1 else: high = mid - 1 return -1 @flow.task def measure_time(func, arr, target): start_time = time.time() func(arr, target) end_time = time.time() return end_time - start_time @flow.task def generate_data_and_measure(): sizes = [100, 1000, 5000, 10000, 50000, 100000] linear_times = [] binary_times = [] for size in sizes: arr = random.sample(range(size * 2), size) target = random.choice(arr) sorted_arr = sorted(arr) linear_time = measure_time(linear_search, arr, target) binary_time = measure_time(binary_search, sorted_arr, target) linear_times.append(linear_time) binary_times.append(binary_time) return sizes, linear_times, binary_times @flow.task def plot_results(sizes, linear_times, binary_times): plt.plot(sizes, linear_times, label='Búsqueda Lineal') plt.plot(sizes, binary_times, label='Búsqueda Binaria') plt.xlabel('Tamaño del Array') plt.ylabel('Tiempo de Ejecución (segundos)') plt.title('Análisis de Complejidad Temporal') plt.legend() plt.grid(True) buf = io.BytesIO() plt.savefig(buf, format='png') buf.seek(0) img_str = base64.b64encode(buf.read()).decode('utf-8') plt.close() return img_str @flow.task def main(): sizes, linear_times, binary_times = generate_data_and_measure() img_str = plot_results(sizes, linear_times, binary_times) return img_str if __name__ == "__main__": flow.run(main) - [Delicate Gold Time Machine](https://www.flux.ai/gadpvrrr/delicate-gold-time-machine.md) - Welcome to your new project. Imagine what you can build here. - [Cultural Teal Antigravity Battle Room](https://www.flux.ai/gadpvrrr/cultural-teal-antigravity-battle-room.md) - Welcome to your new project. Imagine what you can build here. - [Concerned Aqua Flying Cab](https://www.flux.ai/gadpvrrr/concerned-aqua-flying-cab.md) - Welcome to your new project. Imagine what you can build here. - [Firm Maroon TARDIS](https://www.flux.ai/gadpvrrr/firm-maroon-tardis.md) - Welcome to your new project. Imagine what you can build here. - [Surprised Bronze Translation Collar](https://www.flux.ai/gadpvrrr/surprised-bronze-translation-collar.md) - Welcome to your new project. Imagine what you can build here. - [Legislative Olive Transporter](https://www.flux.ai/gadpvrrr/legislative-olive-transporter.md) - Welcome to your new project. Imagine what you can build here. ## Pages - Pages: **1** --- *Generated from [https://www.flux.ai/gadpvrrr](https://www.flux.ai/gadpvrrr)*