1_Introduction to Algorithms
1_Introduction to Algorithms
Overview
• What is an Algorithm?
• Fundamentals of Algorithmic ‘Problem solving’
• Important Problem Types
• Fundamental Data Structures
What is an
Algorithm?
An 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.
• Running time analysis – Determine how running time increases as the size
of the problem increases ie as per increase time we will determine the
growth in the ‘n’ value (size of the input).
• Euclid’s algorithm for finding the greatest common divisor
• If we subtract smaller number from larger (we reduce larger number),
GCD doesn’t change. So if we keep subtracting repeatedly the larger
of two, we end up with GCD.
• Now instead of subtraction, if we divide smaller number, the
algorithm stops when we find remainder 0.
Important Problem Types
• Sorting
• Searching
• Shortest paths in a graph
• Minimum spanning tree
• Traveling salesman problem
• Knapsack problem
• Chess
• Towers of Hanoi
• Program termination
• list • graph
• array • tree and binary tree
• linked list • set and dictionary
• string
• stack
• queue
• priority queue/heap
Doubly Linked List
• https://www.thecodingdelight.com/doubly-linked-list/