Chapter 3 CIS
Protest loop
(While loop) Do iteration loop before you print (after condition)
Order of magnitude
0(n)Set of functions that grow in a linear fashion. Efficiency classification of an algorithm whose work varies as constant times the input(increases)
Polynomial bounded
Algorithm that does work in the order of 0(n^k). Most common programs are this type except Hamilton circuit
Elegance
Algorithmic equivalent of style. Attributes- if correct, ease of understanding, and efficiency. Clever non obvious approach
Approximation algorithms
Algorithms that partially solve or provide sub optimal solutions to intractable problems
Sequential search algorithm
An algorithm that searches for a target value in a random list by checking each list item in term. Check list in order. One at a time. Much check all of list
Space effficiency
Be judged by the amount of info the algorithm must store in the computers memory in order for it to do its job
Karl Fredrick Gauss
Best known for elegant algorithm he created as a schoolchild.
Space efficiently for copy over
Best: all zeros and no extra space. Worse:no zeros, uses n extra spaces.
Worst case
Big input list (sequential search)!Greatest amount of work algorithm does
Best case
Big input list(sequential search algorithm)it is the smallest amount an algorithm does
Ease of understanding
Clarity. Ease of handling is a high desirable characteristic of an algorithm. Ex Pseudocode and flow charts
Time efficiency best case
Copy over; all zeros and checks each value but doesn't copy it
Attributes of interest
Correctness,ease of understanding, elegance, and efficiency
Shuffle left for time efficiency
Count comparisons looking for 0 and movement of values
Copy over algorithm
Create a second
Copy over algorithm
Create a second, initially empty list. Look at each value in the original. If it is non-zero, copy it to the 2nd lisst
Average caase
Depends on likelihood of different scenarios occurance
Post loop
Do iteration after the loop
Algorithms that conflict
Elegance and ease of understanding
Flops
Floating point operations per second
Binary search algorithm
Given a target and an ordered list of values, find the location of the target in the list, if it occurs,by starting in the middle and splitting the range in 2
Order of magnitude of lg n
Grows very slowly
Sequential sort algoritjm
Keeps moving the larger items toward the back of the list
Bubble sort algorithm
Makes multiple passes through the list from front to back, each time. Each time exchanging pairs of interiors that are out of order
Time efficiency worst case
No zeros. Checks each value and copies it
Exponential growi
O(2^n)
Order n^2 thrv
O(n^2)
Sequential search
Operations most important for the task and occurring frequently. Comparison of taget NAME to each game in the list
Program maintenence
Person modifying eiher to correct eerors or to expand its functionality
Benchmarking
Use to prove efficiency. Runs program in many data sets to be sure it's performance faces with in required limits; timing the same algorithm on 2 different machines
Ease of understandig
Useful for checking correctness and program maintenance
Benchmarking
Useful for rating one machine against another and rating how sensitive a profile algorithm with respect to various variations
Shuffle left for specs efficiency
Uses no significant space beyond input
Intractable
Problems with no ply bounded solutions: Hamilton circuit, traveling salesperson, bin packing, and chess
Sorting
Putting a list of values into numeric or alphabetical order. Past repeatedly over the unsorted portion of list. Each pass sect highest remaining value. Move value to end if unsorted values
Short sequential seatch
Requires a sorted list and stops once it passed places where the target could occur
Shuffle left algorithm
Search for 0s left and right. When zeros if found, shift all values to its right ind cell to the left
Best case
Sequential search ;Target found with the first composition
Worse case
Sequential search. Target never found or last value
Average
Sequential search; of each value is equal likely to be searched, work does varies from a 1-n, averages to n/2
Order n^2
Set of functions whose growth is in the order n^2
Worse case
Shuffle left; Everything is zero, movement values; then n - 2 values etc.
Best case
Shuffle left; No terms
Smart bubble sort
Stops when no exchanges occur on a given pass
Analysis of algorithms
Study of the Efficiency of an algorithm. Important part of Computer science
Efficency
Term used to describe an algorithms careful use of time and space resources. In addition to correctness,ease of understanding, and elegance. Extremely desirable attribute of an algorithm
Searching
The task finding a specific value of a list of values; or decisive if it's not there