Docsity

This is a reviewer for Algorithm, Summaries of Mathematics

Toggle sidebar
bg1
ALCOM REVIEWER
• Practical – Web Developer, Mobile Developer, System Developer, Game
Developer,
Database Administrator, Networking Administrator, Penetration Tester
• Theoretical – Computer Scientist, Artificial Intelligence Researcher,
Mathematician, Cybersecurity Researcher
Algorithmics is the study of algorithms. It is the cornerstone of computer science.
• A book, named Algorithmics : the Spirit of Computing, by David Harel:
• “Algorithmics is more than a branch of computer science. It is the core of
computer science, and in all fairness, can be said to be relevant to most of
science, business, and technology”
WHAT IS AN ALGORITHM?
Algorithm - Is a sequence of unambiguous instructions for solving a problem, i.e. for
obtaining a required output for any legitimate input in a finite amount of time.
Every algorithm development starts with a problem.
1. Problem: an inquiry starting from given conditions to investigate or
demonstrate a fact, result, or law.
2. Algorithm: is a set of instructions in solving a problem
3. Computer: is a device where the algorithm is fed and follows it’s instruction
4. Input: To test the algorithm we need inputs
5. Output: Is the result of processing the inputs into the computer.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download This is a reviewer for Algorithm and more Summaries Mathematics in PDF only on Docsity!

ALCOM REVIEWER

  • Practical – Web Developer, Mobile Developer, System Developer, Game

Developer,

Database Administrator, Networking Administrator, Penetration Tester

  • Theoretical – Computer Scientist, Artificial Intelligence Researcher,

Mathematician, Cybersecurity Researcher

Algorithmics is the study of algorithms. It is the cornerstone of computer science.

  • A book, named Algorithmics : the Spirit of Computing, by David Harel:
  • “Algorithmics is more than a branch of computer science. It is the core of

computer science, and in all fairness, can be said to be relevant to most of

science, business, and technology”

WHAT IS AN ALGORITHM?

Algorithm - Is a sequence of unambiguous instructions for solving a problem, i.e. for

obtaining a required output for any legitimate input in a finite amount of time.

Every algorithm development starts with a problem.

  1. Problem : an inquiry starting from given conditions to investigate or

demonstrate a fact, result, or law.

  1. Algorithm : is a set of instructions in solving a problem
  2. Computer : is a device where the algorithm is fed and follows it’s instruction
  3. Input : To test the algorithm we need inputs
  4. Output : Is the result of processing the inputs into the computer.

Example:

Create an algorithm that accepts 1 integer input and 1Boolean output. The algorithm

determine whether the integer input is a odd or even number. Odd is represented by

false Boolean value while even is represented by true Boolean value. Condition: No

modulo operation

x = integer input y = Boolean output

For x >= 0 if x == 0 { y = true

end program

} else { y = false x = x - 2 if x < 0 {

end program

Example : Create an algorithm that get the GCD(Greatest common divisor) of two

positive integer inputs and produce an positive integer output.

Getting the GCD has many different algorithms to solve the problem:

**- Middle-school procedure

  • Consecutive integer checking
  • Euclid’s Algorithm**

Middle-school procedure

  • Remember the “Factor Tree”

Euclid’s Algorithm

Advantages of Euclid

  • Easier to understand and to read
  • Feasible
  • Will not work in our current computer architecture
  • It’s more time and space efficient
  • Will work when one of the inputs is 0

Fundamentals of algorithmic problem solving

  • It is very important to specify exactly the set of instances the algorithm needs to

handle. This what is called an “ instance ”, means defining the set of inputs.

➢ The vast majority of algorithms in use today are still destined to be programmed

for a computer closely resembling the von Neumann machine —a computer

architecture outlined by the prominent.

➢ Hungarian-American mathematician John von Neumann (1903–1957), in

collaboration with A. Burks and H. Goldstine, in 1946.

There are a lots of techniques in designing algorithms. Most of our lesson will be

focusing on those techniques. Here are some techniques:

➢ Exhaustive Search and Brute Force

➢ Decrease and Conquer

➢ Divide and Conquer

➢ Transform and Conquer

➢ Space and Time Trade off

These are the two options that are most widely used nowadays for specifying

algorithms.

  • Pseudocode
  • Flowchart
  • Simplicity – It is a characteristic of an algorithms that is easily to understand,

more concise and clear. And it is easy to implement to our programs. (Example

GCD algorithms, Euclids, Middle-school, consecutive integer)

  • Generality – It is a characteristic of an algorithms that defined that an algorithms

has limitation, it is identified which inputs it takes.

Coding the Algorithm - The last fundamentals of algorithm problem solving

The Von Neumann Computer Architecture

It looks like the graphical representation of an algorithm

Random Access Memory (RAM) – is the essence of the architecture.

RAM - works as the central assumption is that instructions are executed one after

another one operation at a time.

Algorithms that execute one after another one is called sequential algorithms.

There’s also an algorithm that execute concurrent or parallel to one another. This is

what you called a parallel algorithms.

RAM follow the concept of instruction tables in which the algorithm is executed.

To demonstrate how algorithms are translated into assembly , or we can use

instruction table to represent in the Von Neumann Architecture.

0x

0x

0x

Commands (Right)

Memory Address (Left)

  • Instruction table

always starts at the

first memory address

  • Then commands are executed

one by one

  • This memory address will execute first. But there’s no command assigned to this

memory address

  • When a memory address has no command, it will just skip the memory address

and proceeds to the next

mov command – literally means move. In 0x00004, command means move 5 to

memory 0x00001.

  • In the instruction table, the syntax is

command destination-memory, value

  • After executing a command it will move to the next memory address

add command – one of the arithmetic commands, this command means adding the

value of two memory address or fix value.

Syntax is add memory-address1, memory-address

  • Since the result of the arithmetic command is stored in 0x00006, we need to

move the result to an empty memory, which is 0x00003.

end command – this indicates that the program has finish and stop the process.

Without the end command, the RAM/Program assumes that it will execute again by

returning to memory 0x

mov command – use to move data memory to one memory address to another

0x00004 mov 0x00001,

0x00005 mov 0x00001,

0x00006 add 0x00001,

0x

0x00007 mov 0x00003,

0x

0x00008 end

Closest-pair problem is finding the closest pair among n points.

Convex-hull problem is finding the smallest convex polygon that would include all

the points of a given set.

Numerical problems are problems that involve mathematical objects of continuous

nature: solving equations and systems of equations, computing definite integrals,

evaluating function and so on.

Fundamentals of data structures

  • Data structures plays a critical role in design and analysis of algorithms.
  • Data structures tells how the data are organized in the memory.
  • Data structure can be defined as a particular scheme of organizing related data

items.

There are different kinds of data structure:

  • Linear Data Structure
  • Graph
  • Trees

Linear Data Structure – is a data structure that the data are aligned in linear to the

memory.

There two most important linear data structure:

  • Arrays is a sequence of n items of the same data type that are stored

contiguously in computer memory and made accessible by specifying a value of

the array’s index.

  • Arrays is a well-known data structure since this one of the basic foundation of

learning programming.

  • Linked list is a sequence of zero or more elements called nodes , each

containing two kinds of information: some data and one or more links called

pointers to other nodes of the linked list.

  • Linked List – are different in memory in the RAM. It uses pointers to direct the

next memory address it follows.

There are two type of linked list: singly linked list and doubly linked list.

  • Singly Linked List - each node, except the last one, contains a single pointer

to the next element.

  • Doubly Linked List - in which every node , except the first and the last ,

contains pointers to both its successor and its predecessor

Graphs

Informal Definition : a collection of points in the plane called “vertices” or “nodes,”

some of them connected by line segments called “edges” or “arcs.”

Formal Definition : a graph G=〈V,E〉is defined by a pair of two sets: a finite non

empty set V of items called vertices and a set E of pairs of these items called edges.

  • There is this new computer in development called the “ Quantum Computer ”,

which uses physics concepts to solve computational problems. Which they say

can revolutionize all computing technologies

  • The first thing to consider in Analysis Framework is the input’s size. In which can

be represented as n.

Input’s size will greatly affects the space and time complexity of all algorithms.

Input size is the foundation of analysis of algorithms. Most algorithms depends on how

much space and time they consumed depending on the input.

Example of computational problems that affects the time and space complexity :

  • Summation of natural numbers which n is set as the maximum value.

Problem: Summation of natural numbers which n is set as the maximum value.

If every add operation executes 10 seconds, how many seconds does it takes does this

function will take?

Case 1:

Let n = 5

p(n) = n + (n - 1) + (n - 2) + … + (n - n)

p(5) = 5 + 4 + 3 + 2 + 1 + 0

p(5) = 15

This takes 50 seconds to execute

  • But when analyzing time complexity, we don’t use time unit such as seconds,

milliseconds, etc… Because every computers have different time unit in

executing operations.

Example:

Two parts in the analysis framework:

First, we use the Input’s Size to determine how much space and time the algorithm will

consume.

Second, Operation Counting, we determined how many operations that the algorithm

will execute, since using time unit is not efficient!

Now lastly, the Order of Growth

Order of Growth - is determining the algorithm’s operation count as input goes

larger and larger until infinity. It is also a way of computer scientist in categorize where

the growth of algorithms grows.

Order of Growth : Basic asymptotic efficiency classes:

Algorithms running at logarithmic time

runs at when the algorithm total

operation count gets smaller by dividing

them to halves.

Example:

Binary Tree search algorithms

1 constant

log 𝑛 logarithmic

𝑛 linear

𝑛 log 𝑛 linearithmic

2

quadratic

3

cubic

𝑛

exponential

𝑛! factorial

o Second , for some important problems—e.g., sorting, searching, matrix

multiplication, string matching — the brute-force approach yields

reasonable algorithms of at least some practical value with no limitation on

instance size.

o Third , the expense of designing a more efficient algorithm may be

unjustifiable if only a few instances of a problem need to be solved and a

brute-force algorithm can solve those instances with acceptable speed.

o Fourth , even if too inefficient in general, a brute-force algorithm can still

be useful for solving small-size instances of a problem.

o Finally , a brute-force algorithm can serve an important theoretical or

educational purpose as a yardstick with which to judge more efficient

alternatives for solving a problem.

Selection Sort

  • scanning the entire given list to find its smallest element and exchange it

with the first element, putting the smallest element in its final position in the

sorted list.

  • scan the list, starting with the second element, to find the smallest among

the last n − 1 elements and exchange it with the second element, putting the

second smallest element in its final position

  • is an algorithm that selects the smallest element from an unsorted list in

each iteration and places that element at the beginning of the unsorted list.