The Objective Line Method

The Objective Line Method

Sorting Algorithms

  • Bubble Sort works through comparisons and swaps to sort an array. It compares adjacent elements and swaps them if they are in the wrong order. It has a worst-case and average time complexity of O(n²).

  • Quicksort is a divide and conquer algorithm. It works by selecting a ‘pivot’ from the array and partitioning the other elements into two arrays, according to whether they are less than or greater than the pivot. The pivot then remains in its final position. QuickSort has an average time complexity of O(n log n) but a worst-case time complexity of O(n²).

Bin Packing Algorithms

  • The First Fit algorithm places each object in the first bin that can accommodate it. If there is no such bin, it opens a new bin.

  • The First Fit Decreasing algorithm first sorts the objects in decreasing order, and then applies the First Fit algorithm.

  • Full Bin (or Best Fit) algorithm places each object in the tightest spot possible, i.e. it attempts to fill the bins as fully as possible.

Graphs

  • Knowledge of graph theory is essential. Understand that in a graph, nodes (or vertices) are connected by edges. These can either be directed (called arcs) or undirected.

  • Subgraphs, Walks, Paths, Cycles, and Connectivity are fundamental graph concepts; paths do not repeat vertices, and cycles are paths that start and end at the same vertex. A graph is connected if there is a path between every pair of unique vertices.

  • The degree of a node is the number of edges that meet at that node; in directed graphs, you have in-degree and out-degree, which count the number of incoming and outgoing edges respectively.

The Planarity Algorithm

  • The planar graph is a graph that can be drawn on a plane without the edges crossing. Non-planar graphs cannot be drawn on a plane without crossings.

  • To determine whether a graph is planar, you can use the Kuratowski’s theorem. This theorem states that a graph is planar if and only if it does not contain a ‘K5’ (complete graph on five vertices) or ‘K3,3’ (complete bipartite graph on six vertices, three of which connect to each of the other three) as a subgraph.

Spanning Trees and Kruskal’s Algorithm (AS)

  • A spanning tree is a subgraph of a graph that contains all vertices of the graph and is a tree.

  • Kruskal’s algorithm finds a minimum spanning tree for a connected weighted graph. It works by adding the lightest edge that would not create a cycle until all vertices are in the tree.

Prim’s Algorithm (AS)

  • Prim’s algorithm also finds a minimum spanning tree. It does this by starting with an arbitrary vertex and adding the lightest edge from the existing structure to a new vertex.

  • One key difference between Kruskal’s Algorithm and Prim’s Algorithm is that Prim’s focuses on vertices, whereas Kruskal’s focuses on edges.