Category: Algorithms & Data Structures

  • Title: Optimization of Dijkstra’s Algorithm for Shortest Path Finding

    1. Running the codes on your own PC, showing and explaining the result. (explain the result)
    2. Parts of the code that belongs to the optimization (the modifications made from the
    original code).
    (tell me the code that you have changed)
    3. Describe and justify your approach. Compare your approach to the bare bones
    implementation. In particular give the average number of vertices examined. (give me explainition for this one)

  • Title: Exploring Binary Tree Removal, Priority Queues, and Sorting Algorithms in Java

    Q1-Given below is a Java method to remove a node from a binary tree. Your task is to:
    Write a detailed explanation for each block or segment of the provided code. A block or segment is a logical grouping of lines that perform a specific task or operation together.
    Ensure your explanations are clear, concise, and demonstrate your understanding of the code’s functionality.
    private BinaryNode remove(AnyType x, BinaryNode t) {
    if (t == null)
    return t;
    int compareResult = x.compareTo(t.element);
    if (compareResult < 0) t.left = remove(x, t.left); if (compareResult > 0)
    t.right = remove(x, t.right);
    else if (t.left != null && t.right != null) { t.element = findMin(t.right).element;
    t.right = remove(t.element, t.right);
    }
    else
    t = (t.left != null) ? t.left : t.right;
    return t;
    }
    Q2-Write Java code to use a priority queue to sort numbers in ascending order.
    Q3-Compare and contrast any four (4) sorting algorithms based on the following factors:
    Time Complexity Space Complexity Ease of Implementation Applications of Algorithm