How can we help?

You can also find more resources in our Help Center.

pseudo code

natural language

boolean condition

algorithm

is a kind of structured English for describing algorithms. It…

a language that has developed naturally in use (as contrasted…

compares two values to each other and then returns either a t…

a set of steps; for a computer program to accomplish

pseudo code

is a kind of structured English for describing algorithms. It…

natural language

a language that has developed naturally in use (as contrasted…

Isolate the lowest bit that is 1 in x

Replace the lowest bit that is 1 with 0

Right propagate the rightmost set bit…

Compute x modulo a power of 2 (y)

x & ~(x - 1)

x & (x - 1)

x | (x & ~(x - 1) - 1)

x & (y - 1)

Isolate the lowest bit that is 1 in x

x & ~(x - 1)

Replace the lowest bit that is 1 with 0

x & (x - 1)

%

return

if

r

//complete greatest... //common divisor... public static int gcd(in…

//complete greatest... //common divisor... public static int gcd(in…

//complete greatest... //common divisor... public static int gcd(in…

//complete greatest... //common divisor... public static int gcd(in…

%

//complete greatest... //common divisor... public static int gcd(in…

return

//complete greatest... //common divisor... public static int gcd(in…

What is an algorithm?

What is asymptotic notation?

Briefly describe and give an example o…

List the 3 methods of resolving recurr…

Series of steps that take inputs and translates them to outpu…

Describes growth. Tells about the runtime of an algorithm.

f(n)=O(g(n)) : g(n) is an upperbound of f(n). ... f(n) = Ω(g(n))…

Master method, substitution, recursion tree.

What is an algorithm?

Series of steps that take inputs and translates them to outpu…

What is asymptotic notation?

Describes growth. Tells about the runtime of an algorithm.

Selection sort

Insertion sort

Shellsort

Mergesort

Find smallest, put at beginning... Best: O(n^2)... Avg: O(n^2)... Wors…

Side-by-side comparison... Best: O(n)... Avg: O(n^2)... Worst: O(n^2)

Insertion sort over a gap... Best: O(n log n)... Avg: depends on ga…

split into sub-arrays... Best: O(n log n)... Avg: O(n log n)... Worst:…

Selection sort

Find smallest, put at beginning... Best: O(n^2)... Avg: O(n^2)... Wors…

Insertion sort

Side-by-side comparison... Best: O(n)... Avg: O(n^2)... Worst: O(n^2)

Selection sort

Binary search

Sequential search

Bubble sort

For all but last element traverse to get largest element... plac…

For sorted element set... Divide in half... Compare if term is grea…

Loop through sorted set until item found

Traverse set... Swap adjacent items if out of order... Repeat until…

Selection sort

For all but last element traverse to get largest element... plac…

Binary search

For sorted element set... Divide in half... Compare if term is grea…

Greedy Algorithm

Divide and Conquer

Recursive Algorithms

Dynamic Programming

an algorithm that follows problem solving heuristic of making…

works by recursively breaking down a problem into two or more…

solve a problem by solving smaller internal instances of a pr…

Break down a problem into smaller and smaller subproblems. At…

Greedy Algorithm

an algorithm that follows problem solving heuristic of making…

Divide and Conquer

works by recursively breaking down a problem into two or more…

Bubble Sort

Quick Sort

Binary Search

First-Fit

1. Write out the the numbers/names given.... 2. Record only each…

1. Write down the list... 2. Select the pivot(mid point)... 3. Now…

1. Use one of the sorting algorithms (quick sort or bubble so…

1. Take the items in the order given ... 2. Place each item in t…

Bubble Sort

1. Write out the the numbers/names given.... 2. Record only each…

Quick Sort

1. Write down the list... 2. Select the pivot(mid point)... 3. Now…

Heapsort

Quicksort

Mergesort

Binary search

Sort in O(1) space, O(nlgn) time.

Sort in O(nlgn) time average case, or O(n**2) worse case

Sort in O(nlgn) time, O(n) space

Search sorted list in O(lgn) time

Heapsort

Sort in O(1) space, O(nlgn) time.

Quicksort

Sort in O(nlgn) time average case, or O(n**2) worse case

Linked List

Stack

Queue

Binary Tree

Head & Tail. Single linked looks forward only. Doubly linked…

LiFo (Last in, first out). Items are "pushed" onto the stack…

FiFo(First in, First out). Items are "enqueue" into queue and…

Root (or Head node) = Very top node... Leaf nodes/Terminal nodes…

Linked List

Head & Tail. Single linked looks forward only. Doubly linked…

Stack

LiFo (Last in, first out). Items are "pushed" onto the stack…

Algorithm

Pseudo Code

Flow chart

Linear Search

Step by step process to solve a problem

Resembles a programming language without any syntax

Diagram that represents an algorithm showing the steps as sha…

Starts at one end of data, works through checking each item i…

Algorithm

Step by step process to solve a problem

Pseudo Code

Resembles a programming language without any syntax

Isolate the lowest bit that is 1 in x

Replace the lowest bit that is 1 with 0

Right propagate the rightmost set bit…

Compute x modulo a power of 2 (y)

x & ~(x - 1)

x & (x - 1)

x | (x & ~(x - 1) - 1)

x & (y - 1)

Isolate the lowest bit that is 1 in x

x & ~(x - 1)

Replace the lowest bit that is 1 with 0

x & (x - 1)

Isolate the lowest bit that is 1 in x

Replace the lowest bit that is 1 with 0

Right propagate the rightmost set bit…

Compute x modulo a power of 2 (y)

x & ~(x - 1)

x & (x - 1)

x | (x & ~(x - 1) - 1)

x & (y - 1)

Isolate the lowest bit that is 1 in x

x & ~(x - 1)

Replace the lowest bit that is 1 with 0

x & (x - 1)

Merge Sort: worst, average, best effic…

Merge Sort: attributes

Merge Sort: explanation of efficiency

Merge Sort: common improvements

O(n log n) b/c it always divides a segment in half at each st…

Stable (equal elements retain their original relationship).... C…

TBD. Note O(n) additional memory is needed

Hybrid: use e.g. InsertionSort when segments get small enough…

Merge Sort: worst, average, best effic…

O(n log n) b/c it always divides a segment in half at each st…

Merge Sort: attributes

Stable (equal elements retain their original relationship).... C…

Define an Algorithm:... What are the 3 w…

Parameter Passing:

Data Structure:... Arrays:

Data Structure:... Records:

A set of instructions to perform a specific task.... 1) Flow ch…

Module is self contained piece of code.... Parameters are essen…

Arrays: Can only hold data of the same data type, and data is…

A record is a set of data items all related to a single entit…

Define an Algorithm:... What are the 3 w…

A set of instructions to perform a specific task.... 1) Flow ch…

Parameter Passing:

Module is self contained piece of code.... Parameters are essen…

Bubble Sort Algorithm

Quick Sort Algorithm

Binary Search Algorithm

Bin Packing Algorithm

1. If there is one number in the list then stop.... 2. Make one…

1. choose the item at mid-point to be first pivot.... 2. write d…

1. Choose the item at midp-point,m.... 2. (i) if T=m then search…

1. Select each item and place in the first available bin than…

Bubble Sort Algorithm

1. If there is one number in the list then stop.... 2. Make one…

Quick Sort Algorithm

1. choose the item at mid-point to be first pivot.... 2. write d…

Algorithm

Sequence

Sub tasks

Iteration

A step-by-step procedure for solving problems

The order in which tasks are carried out

Small steps making up a larger task

When a task is repeated until there is a required outcome

Algorithm

A step-by-step procedure for solving problems

Sequence

The order in which tasks are carried out

binary search

binary search pseudocode

running time of binary search

rate of growth

searches an ordered array for a target value by using the mid…

1. Let min = 1 and max = ... n... 2. Guess the average of max and m…

max possible steps =( base-2 logarithm of n) +1... n= length of…

how fast does the running time of the algorithm grow with the…

binary search

searches an ordered array for a target value by using the mid…

binary search pseudocode

1. Let min = 1 and max = ... n... 2. Guess the average of max and m…

What is an algorithm?

What are the three algorithm constructs?

An algorithm needs to represent the a…

An algorithm needs to represent a situ…

Step by step instructions used to solve a specific problem

Sequence, Selection and Iteration

Selection

Iteration

What is an algorithm?

Step by step instructions used to solve a specific problem

What are the three algorithm constructs?

Sequence, Selection and Iteration

Gale-Shapley Stable Matchings

Algorithms

What are the properties of Asymptotic…

What are common runtimes for algorithms?

Whichever gender proposes is the one that gets worse and wors…

A set of instructions

Transitivity - if f = O(g) and g = O(h), then f = O(h) (same…

linear: computing the maximum, merging two sorted lists... nlog…

Gale-Shapley Stable Matchings

Whichever gender proposes is the one that gets worse and wors…

Algorithms

A set of instructions

What is an Algorithm?

What is a Data Structure?

What is a sorting algorithm?

What is Asymptotic Behavior?

A step-by-step procedure for solving a specific problem.

A method for storing data so that information can be accessed…

...

An abstract analysis of how much faster or slower an algorith…

What is an Algorithm?

A step-by-step procedure for solving a specific problem.

What is a Data Structure?

A method for storing data so that information can be accessed…

algorithm

iterative algorithm

decision making algorithm

sequential algorithm

a process or set of rules to be followed in calculations or o…

a type of algorithm which repeats a series or steps over and…

a type of algorithm which is forced to make one or more decis…

a type of algorithm which follows a logical order or sequence.

algorithm

a process or set of rules to be followed in calculations or o…

iterative algorithm

a type of algorithm which repeats a series or steps over and…

MergeSort and runtime

Mergesort algorithm

Binary Search

DFS + explore

Merge sort... mergesort both halves of the array recursively... unt…

Have an array of n elements... function mergesort (a[1.....n])…

Go to the middle of the array and compare the key with that o…

Explore:... put in the graph G and the vertex v in the method... pr…

MergeSort and runtime

Merge sort... mergesort both halves of the array recursively... unt…

Mergesort algorithm

Have an array of n elements... function mergesort (a[1.....n])…

Find Strongly Connected Component

Disjoint Set

Dijkstra's

Prim and Kruskal Algorithms

- A graph is said to be strongly connected if every vertex is…

Union by rank and path compression:... Three functions:... makeSet(…

Finds shortest distances to all nodes... time: O(|E| + |V| log…

finds minimum spanning tree (MST) ... MSTs are spanning trees o…

Find Strongly Connected Component

- A graph is said to be strongly connected if every vertex is…

Disjoint Set

Union by rank and path compression:... Three functions:... makeSet(…

Definition of big O

Definition of theta

Definition of omega

logb (b^a) =

f: ∃ c, n0 > 0 ∀n >= n0, 0 < = f(n) < = c*g(n)

f: ∃ c1, c2, n0 > 0 ∀n >= n0, 0 < =c1 **g(n) < = f(n) < = c2** c2*g…

f: ∃ c, n0 > 0 ∀n >= n0, 0 < = c*g(n)< = f(n)

a

Definition of big O

f: ∃ c, n0 > 0 ∀n >= n0, 0 < = f(n) < = c*g(n)

Definition of theta

f: ∃ c1, c2, n0 > 0 ∀n >= n0, 0 < =c1 **g(n) < = f(n) < = c2** c2*g…

Adjacency matrix:... Checking if (u, v )…

Breadth First Search

Let G be an undirected graph on n node…

what's an undirecte graph

Adjacency matrix and Adjacency list differences... Conclusion:…

BFS intuition: Explore outward from s in all possible directi…

1 G is connected.... 2 G does not contain a cycle.... 3 G has n − 1…

An undirected graph is a tree if it is connected and does not…

Adjacency matrix:... Checking if (u, v )…

Adjacency matrix and Adjacency list differences... Conclusion:…

Breadth First Search

BFS intuition: Explore outward from s in all possible directi…

Adjacency matrix:... Checking if (u, v )…

Breadth First Search

Let G be an undirected graph on n node…

what's an undirecte graph

Adjacency matrix and Adjacency list differences... Conclusion:…

BFS intuition: Explore outward from s in all possible directi…

1 G is connected.... 2 G does not contain a cycle.... 3 G has n − 1…

An undirected graph is a tree if it is connected and does not…

Adjacency matrix:... Checking if (u, v )…

Adjacency matrix and Adjacency list differences... Conclusion:…

Breadth First Search

BFS intuition: Explore outward from s in all possible directi…

community acquired pneumonia (cap) - o…

strep throat dx

Alveolar-arterial gradient (A-a gradie…

pulmonary embolism

CURB-65... confusion... BUN >/= 20... RR >/= 30... SBP <90, DBP <60... age >…

centor criteria... 1. fever... 2. tonsillar exudate ... 3. anterior ce…

normal 5-15 mmHg... A-a = PAo2 - Pao2... PAo2 = [713 mmHg x 21% -…

wells' criteria... 1. sxs of DVT (3 pts)... 2. no other dx more lik…

community acquired pneumonia (cap) - o…

CURB-65... confusion... BUN >/= 20... RR >/= 30... SBP <90, DBP <60... age >…

strep throat dx

centor criteria... 1. fever... 2. tonsillar exudate ... 3. anterior ce…

Bellman-Ford

Kruskal's

Bogo Sort

Insertion Sort

Shortest path that allows negative edge values. For V-1 itera…

Minimum spanning tree. Build using smallest edges and connect…

Randomize array until everything is sorted

Generate a running sorted list. Insert new number where it be…

Bellman-Ford

Shortest path that allows negative edge values. For V-1 itera…

Kruskal's

Minimum spanning tree. Build using smallest edges and connect…

Loop Invariant

problem instance

correctness

Monotonicity

a property/logical assertion that holds before and after each…

the input needed to compute a solution (example: an input seq…

an algorithm is correct if for all input instances, it halts…

- monotonically increasing: m <= n => f(m) <= f(n)... - monotoni…

Loop Invariant

a property/logical assertion that holds before and after each…

problem instance

the input needed to compute a solution (example: an input seq…

Analysis of Algorithms

Searching and Sorting

Greedy Algorithms

Dynamic Programming

Asymptotic Analysis, Worst, Average and Best Cases, Asymptoti…

Binary Search, Selection Sort, Bubble Sort, Insertion Sort, M…

Activity Selection Problem, Kruskal's Minimum Spanning Tree A…

Overlapping Subproblems Property, Optimal Substructure Proper…

Analysis of Algorithms

Asymptotic Analysis, Worst, Average and Best Cases, Asymptoti…

Searching and Sorting

Binary Search, Selection Sort, Bubble Sort, Insertion Sort, M…

Quicksort algorithm

Quicksort complexity

Mergesort algorithm

Mergesort complexity

1. choose pivot... 2. split list into greater and lesser... 3. recu…

avg: theta(n log n)... worst: O(n^2)

1. split input into lists of length 1... 2. repeatedly merge sub…

O(n log n)

Quicksort algorithm

1. choose pivot... 2. split list into greater and lesser... 3. recu…

Quicksort complexity

avg: theta(n log n)... worst: O(n^2)

Algorithm

In CS algorithms must have features such

steps to develop program

Types of Algorithms

steps for solving a given problem

1. it must have input... 2. it must give at least one output... 3.…

1.Reuirements Specification (input and output)... 2.Design (تحدي…

1. Searching Algorithms... 2.Sorting Algorithms... 3. Compression A…

Algorithm

steps for solving a given problem

In CS algorithms must have features such

1. it must have input... 2. it must give at least one output... 3.…

Algorithm

Diamond-Shaped Boxes

Efficiency (of an Algorithm)

Flow Diagram

A finite sequence of instructions for solving a problem.

Used for questions which then determine future actions.

A measure of the "run-time" of the algorithm.

A pictorial representation of an algorithm.

Algorithm

A finite sequence of instructions for solving a problem.

Diamond-Shaped Boxes

Used for questions which then determine future actions.

worst case

asymptotic analysis

fast algorithm

linear time algorithm

dont care about where the input array n is coming from. Worst…

focus on when input sizes are very VERY BIG... suppress constant…

worst case running time grows slowly with large input size

number of instructions grows proportional to input size

worst case

dont care about where the input array n is coming from. Worst…

asymptotic analysis

focus on when input sizes are very VERY BIG... suppress constant…

Algorithm

Low level programming language

High level programming language

Every algorithm can be constructed usi…

A precise sequence of instructions for processes that can be…

A programming language that captures only the most primitive…

A programming language with many commands and features design…

Sequencing, selection, and iteration

Algorithm

A precise sequence of instructions for processes that can be…

Low level programming language

A programming language that captures only the most primitive…

MD5

SHA-1

SHA-2

HMAC-MD5

Hashing-Integrity... Creates 128-bit hashes

Hashing-Integrity... Creates 160-bit hashes

Hashing-Integrity... Creates 224-, 256-, 384, or 512-bit hashes

Integrity/Authenticity... Creates 128-bit hashes

MD5

Hashing-Integrity... Creates 128-bit hashes

SHA-1

Hashing-Integrity... Creates 160-bit hashes