{% extends "base.html" %} {% block title %}Greedy Algorithms | USSU Algorithm Analyzer v4.0 {% if result %}

💎 Greedy Strategy Analysis

Greedy Choice

{{ result.algorithm }} — {{ result.iterations }} greedy choices made, {{ result.comparisons }} comparisons.

Local Optimal → Global Optimal

At each step, made locally optimal decision without reconsideration. Proof by exchange argument or matroid theory.

Result

Solution found in {{ "%.4f"|format(result.execution_time_ms) }}ms. Complexity: {{ result.time_complexity }}.

{% endif %} {% endblock %} {% block content %}

Select Algorithm

Algorithm Info

Activity Selection

O(n log n) Optimal

Sort by finish time, greedily pick compatible activities. Classic greedy proof by exchange argument.

Fractional Knapsack

O(n log n) Optimal

Sort by value/weight ratio, take fractions. Unlike 0/1 knapsack, greedy works here.

Huffman Coding

O(n log n) Optimal Prefix

Build optimal prefix-free binary code using min-heap. Minimizes expected code length.

{% if result %}

Result

Algorithm
{{ result.algorithm }}
Time (ms)
{{ "%.4f"|format(result.execution_time_ms) }}
Memory
{{ "%.2f"|format(result.memory_used_kb) }} KB
Iterations
{{ result.iterations }}
Comparisons
{{ result.comparisons }}
Complexity
{{ result.time_complexity }}
Time (ms)
{{ "%.4f"|format(result.execution_time_ms) }}
Iterations
{{ result.iterations }}
Comparisons
{{ result.comparisons }}
{% if result.selected is defined %}Selected: {{ result.selected }}
{% endif %} {% if result.count is defined %}Count: {{ result.count }}
{% endif %} {% if result.max_value is defined %}Max Value: {{ "%.2f"|format(result.max_value) }}
{% endif %} {% if result.selected_items is defined %}Selected Items: {{ result.selected_items }}
{% endif %} {% if result.codes is defined %}Codes: {{ result.codes }}
Total Bits: {{ result.total_bits }}
Avg Bits: {{ "%.2f"|format(result.average_bits) }}
{% endif %} {% if result.total_profit is defined %}Total Profit: {{ result.total_profit }}
Scheduled: {{ result.scheduled_jobs }}
{% endif %} {% if result.min_coins is defined %}Min Coins: {{ result.min_coins }}
Coins Used: {{ result.coins_used }}
{% endif %} {% if result.warning is defined %}âš  {{ result.warning }}
{% endif %}
{% endif %} {% if result %}

💎 Greedy Strategy Analysis

Greedy Choice

{{ result.algorithm }} — {{ result.iterations }} greedy choices made, {{ result.comparisons }} comparisons.

Local Optimal → Global Optimal

At each step, made locally optimal decision without reconsideration. Proof by exchange argument or matroid theory.

Result

Solution found in {{ "%.4f"|format(result.execution_time_ms) }}ms. Complexity: {{ result.time_complexity }}.

{% endif %} {% endblock %} {% block extra_scripts %} {% if result %}

💎 Greedy Strategy Analysis

Greedy Choice

{{ result.algorithm }} — {{ result.iterations }} greedy choices made, {{ result.comparisons }} comparisons.

Local Optimal → Global Optimal

At each step, made locally optimal decision without reconsideration. Proof by exchange argument or matroid theory.

Result

Solution found in {{ "%.4f"|format(result.execution_time_ms) }}ms. Complexity: {{ result.time_complexity }}.

{% endif %} {% endblock %}