Module 6

Algorithms

Outline Chapter 7

Chapter 7 Problem Solving and Algorithms

7.1 How to Solve Problems

Ask Questions

Look for Familiar Things

Divide and Conquer

Algorithms

Computer Problem-Solving Process

Summary of Methodology

Testing the Algorithm

7.2 Algorithms with Simple Variables

An Algorithm with Selection

Algorithms with Repetition

7.3 Composite Variables

Arrays

Records

7.4 Searching Algorithms

Sequential Search

Sequential Search in a Sorted Array

Binary Search

7.5 Sorting

Selection Sort

Bubble Sort

Insertion Sort

7.6 Recursive Algorithms

Subprogram Statements

Recursive Factorial

Recursive Binary Search

Quicksort

7.7 Important Threads

Information Hiding

Abstraction

Naming Things

Testing

Ethical Issues: Open-Source Software


Related FGCU Courses

http://icarus.fgcu.edu:8080/CourseDescriptions/

COP 3530 Data Structures & Algorithms

SE Requirement

Data structure design, implementation, application, and analysis are explored. Abstract data types (ADTs) are introduced and uses of interfaces is emphasized. Topics include stacks, queues, linked lists, and trees. Recursion is revisited, the O notation is introduced, and computational complexity of searching and sorting algorithms are explored.

Prerequisites: COP 3003 and MAD 3107

ISM 2051 Intro Website Development w/DB

Elective

This course prepares students as website developers who can create an attractive, socially, culturally sensitive site containing dynamic components as well as static components using an integrated tool with a database.

Lesson

Day One

  • Chapter questions review

  • Algorithm - Unambiguous instructions for solving a problem or subproblem in a finite amount of time using a finite amount of data

    • An algorithm must be written before any coding in a programming language can be done

      • Making a peanut butter and jelly sandwich

      • 49e?

      • Card trick

      • Country trick

      • Computing the average of a list of numbers

      • Finding the min

  • Searching

    • Phone Book

      • Linear (go through one at a time)

      • Binary (divide and conquer)

        • Guess a number

          • Sorted vs unsorted

        • Recursion

  • What do programmers actually do? video (9:19)

  • Intro to Algorithms Brilliant course

  • Plus Delta


Day Two

  • Sorting

  • Introduction to Efficiency / Big O (more in chapter 18)

    • (n - 1) + (n - 2) + ... + 1

    • n(n - 1) / 2

    • n2 / 2 - n / 2

    • 1,000,000 items = 500,000,000,000 - 500,000

    • basically n2 / on the order of (ignoring / 2 and - n / 2)

    • O(n2)

      • Multiplying two n-digit numbers by a simple algorithm; simple sorting algorithms, such as bubble sort, selection sort and insertion sort

      • Side note: lattice multiplication

    • Cheat Sheet


Project Review

CSS

Project Preview

Web site creation

  • Review storyboard

  • No spaces in file names

  • Add links

  • Overview of GitHub. Basic terminology: git, repository (remote & local), commit, push, pull.

  • Create GitHub repository named username.github.io on github.com, initialize with README, in Settings choose to use GitHub Pages

  • Install / open GitHub Desktop

    • Clone repository to OneDrive folder

    • Move contents of website folder into repository

    • Commit and Push

  • Any problems with GitHub Desktop, just use github.com to upload / edit.

Algorithms and Complexity (AL)

"Algorithms are fundamental to computer science and software engineering. The real-world performance of any software system depends on: (1) the algorithms chosen and (2) the suitability and efficiency of the various layers of implementation. Good algorithm design is therefore crucial for the performance of all software systems. Moreover, the study of algorithms provides insight into the intrinsic nature of the problem as well as possible solution techniques independent of programming language, programming paradigm, computer hardware, or any other implementation aspect. An important part of computing is the ability to select algorithms appropriate to particular purposes and to apply them, recognizing the possibility that no suitable algorithm may exist. This facility relies on understanding the range of algorithms that address an important set of welldefined problems, recognizing their strengths and weaknesses, and their suitability in particular contexts. Efficiency is a pervasive theme throughout this area. This knowledge area defines the central concepts and skills required to design, implement, and analyze algorithms for solving problems. Algorithms are essential in all advanced areas of computer science: artificial intelligence, databases, distributed computing, graphics, networking, operating systems, programming languages, security, and so on."

Basic Analysis

KA Topics:

  • Differences among best, expected, and worst case behaviors of an algorithm

  • Asymptotic analysis of upper and expected complexity bounds

  • Big O notation: formal definition

  • Complexity classes, such as constant, logarithmic, linear, quadratic, and exponential

  • Empirical measurements of performance

  • Time and space trade-offs in algorithms

KA Learning Outcomes:

  1. Explain what is meant by “best”, “expected”, and “worst” case behavior of an algorithm.

  2. In the context of specific algorithms, identify the characteristics of data and/or other conditions or assumptions that lead to different behaviors. [Assessment]

  3. Determine informally the time and space complexity of simple algorithms. [Usage]

  4. State the formal definition of big O. [Familiarity]

  5. List and contrast standard complexity classes. [Familiarity]

  6. Perform empirical studies to validate hypotheses about runtime stemming from mathematical analysis. Run algorithms on input of various sizes and compare performance. [Assessment]

  7. Give examples that illustrate time-space trade-offs of algorithms. [Familiarity]

Algorithmic Strategies

KA Topics:

  • Brute-force algorithms

  • Greedy algorithms

  • Divide-and-conquer (cross-reference SDF/Algorithms and Design/Problem-solving strategies)

  • Recursive backtracking

  • Dynamic Programming

KA Learning Outcomes:

  1. For each of the strategies (brute-force, greedy, divide-and-conquer, recursive backtracking, and dynamic programming), identify a practical example to which it would apply. [Familiarity]

  2. Use a greedy approach to solve an appropriate problem and determine if the greedy rule chosen leads to an optimal solution. [Assessment]

  3. Use a divide-and-conquer algorithm to solve an appropriate problem. [Usage]

  4. Use recursive backtracking to solve a problem such as navigating a maze. [Usage]

  5. Use dynamic programming to solve an appropriate problem. [Usage]

  6. Determine an appropriate algorithmic approach to a problem. [Assessment]

Fundamental Data Structures and Algorithms

KA Topics:

  • Simple numerical algorithms, such as computing the average of a list of numbers, finding the min, max, and mode in a list, approximating the square root of a number, or finding the greatest common divisor

  • Sequential and binary search algorithms

  • Worst case quadratic sorting algorithms (selection, insertion)

  • Worst or average case O(N log N) sorting algorithms (quicksort, heapsort, mergesort)

  • Hash tables, including strategies for avoiding and resolving collisions

  • Binary search trees

    • Common operations on binary search trees such as select min, max, insert, delete, iterate over tree

  • Graphs and graph algorithms

    • Representations of graphs (e.g., adjacency list, adjacency matrix)

    • Depth- and breadth-first traversals

KA Learning Outcomes:

  1. Implement basic numerical algorithms. [Usage]

  2. Implement simple search algorithms and explain the differences in their time complexities. [Assessment]

  3. Be able to implement common quadratic and O(N log N) sorting algorithms. [Usage]

  4. Describe the implementation of hash tables, including collision avoidance and resolution. [Familiarity]

  5. Discuss the runtime and memory efficiency of principal algorithms for sorting, searching, and hashing. [Familiarity]

  6. Discuss factors other than computational efficiency that influence the choice of algorithms, such as programming time, maintainability, and the use of application-specific patterns in the input data. [Familiarity]

  7. Explain how tree balance affects the efficiency of various binary search tree operations. [Familiarity]

  8. Solve problems using fundamental graph algorithms, including depth-first and breadth-first search. [Usage]

  9. Demonstrate the ability to evaluate algorithms, to select from a range of possible options, to provide justification for that selection, and to implement the algorithm in a particular context. [Assessment]