Structured Programming and Problem Solving

Structured Approach:

Tools for Designing Algorithms:

  1. Flow diagrams and pseudocode are commonly used for designing algorithms.
  2. Pseudocode is generally more useful.
  3. Most logic errors occur at decision blocks.

Did I just add that to use an ordered list? Yes.

Thinking Concurrently:

Problem Recognition:

Computable Problems:

Computable problem: A problem is computable if there is an algorithm that can solve every instance of the problem in a finite number of steps.

Methods of Problem Solving:

Graphs:

A strategy after initially abstracting a problem to a graph is "graph unfolding" which basically means constructing a clearer, isomorphic graph (to the original).

This particularly helped in problems such as the "knights tour" we covered in lesson, allowing us to quickly see the winning strategy.

A graphical, unfolded representation.

Problem Solving:

Visualization:

Usually consists of thinking of the problem as a graph, removing many unnecessary details or spotting a nice trick which trivializes the problem.

Backtracking:

Backtracking algorithms begin with an empty solution and extend the solution step-by-step. It recursively goes through all of the different ways that a solution may be constructed. An example of this is a depth-first-search.

Data Mining:

The process of digging through big data sets to discover hidden connections and predict future trends. YouTube uses this to recommend "good videos" by looking at variable data points provided by its many users, or Google on how "happy" a user is with its speech recognition when searching (do they retry the search because what they said was not correctly transcribed).

Intractable problems

Problems that would take an unreasonably long time to find a solution. For example, the travelling salesman problem.

The optimal solution for this problem may be found using brute force, but the runtime to find this solution grows exponentially with the number of towns added. (time complexity of O(n!) as it checks every combination of routes for n towns)

Problems like these are often Heuristically solved. We would rather find a near-optimal solution in a short amount of time than find the optimal solution in a very long amount of time because the near-optimal solution is good enough for its purpose. For the travelling salesman problem, programmers have used techniques such as simulated annealing to find a near-optimal solution.

Performance Modeling:

The process of simulating different user and system loads on a computer using a mathematical approximation, rather than doing actual performance testing which may be difficult and expensive. For example, used to test the performance of a network under different conditions, generally used to assist with planning a new system which is suited to the requirements of an organization.

Pipelining:

Splitting tasks into smaller parts and overlapping the processing of each part of the task. Often used in microprocessors so that while one instruction is being fetched, another is decoded and a third executed. (like an assembly line)

A nicer "conceptual" definition is doing multiple tasks step by step, but instead of waiting for one task to finish before starting the next, we start the next task as soon as we finish the first step of the previous one. This is possible because you can wait for data and instructions in a "logical pipeline".