Week 1 – CST370 – Design and Analysis of Algorithms
This week was a combination of week 0 and week 1. We were
required to set up a GitHub account, if we did not have one already, to
complete our homework assignments with GitHub Classroom. Homework 0 required us
to write a program that reads two integer numbers from a user and displays the
sum and difference of the two numbers. We also needed to make sure that the
difference between the two numbers is always 0 or positive. The purpose of Homework
0 was to get familiar with GitHub Classroom, set up our IDE environment, and submitting
to Canvas. The topics covered this week included Euclid’s Algorithm for GCD
calculation, important problem types, fundamental data structures, and algorithm
analysis framework.
Euclid’s Algorithm for GCD calculation is an algorithm that takes
two numbers and finds the greatest common divisor by repeating the equality gcd(m,
n) = gcd(n, m mod n) until m mod n is equal to zero. The last value of m will
be the greatest common divisor of the two numbers.
Some of the important problem types covered this week
included graph, sorting and searching. A graph is composed of nodes or vertices
and lines or edges. Graphs can be used to model real life applications like
transportation, communication networks, and project scheduling. We use sorting to
arrange items in either ascending or descending order. Sorting has many applications,
and it serves as the basis of many other algorithms. Searching problems involve
finding a given value, called a search key, in a given set. There are different
types of searching techniques like sequential search, binary search, and
hashing. Sorting a data set will often make searching more efficient.
The material for this week also included a review of fundamental
data structures such as linked lists, stacks, queues, graphs, and trees. Linked
lists are a sequence of elements called nodes which contain data and a pointer
that links to other nodes in the linked list. A stack is a list in which insertions
and deletions can only be made at the end and it operates in a last-in-first-out
(LIFO) fashion. A queue is a list where elements are added in the rear and
deleted from the front in a first-in-first-out fashion. We covered more on
graphs such as directed and undirected graphs as well as the Traveling Salesman
Problem which finds the shortest possible route that visits each city exactly
once and returns to the origin city. A tree is a special type of graph called a
connected acyclic graph in which the number of edges is always equal to one
less than the number of vertices. Binary search trees are represented as a node
with a value for the vertex and pointers to its left and right child.
Lastly, we learned about algorithm analysis framework. We
analyze algorithms to determine their efficiency by measuring the amount of resources
necessary to execute the algorithm, which are typically time and memory. We will
be focusing on time efficiency. We first need to identify the algorithm’s basic
operation. This is the operation that is most frequently performed, and it is
usually found in the algorithm’s innermost loop. The objective of algorithm
analysis is to determine the order of growth. There are eight common time
complexities for the order of growth constant time, logarithmic time, linear
time, linearithmic time, quadratic time, cubic time, exponential time, and
factorial time.
Comments
Post a Comment