L1 - Introduction to Algorithms.pdf
Document Details
![ZippyPelican](https://quizgecko.com/images/avatars/avatar-14.webp)
Uploaded by ZippyPelican
Tags
Related
- Linear Regression Lecture Notes PDF
- COMP 8547 Advanced Computing Concepts Fall 2024 Lecture Notes PDF
- Algorithm Design and Applications PDF
- Data Structure and Algorithm (BCSE202L) Lecture Notes PDF
- Data Structures and Algorithm Analysis in C++ 4th Edition PDF
- MAULANA ABUL KALAM AZAD UNIVERSITY OF TECHNOLOGY, WEST BENGAL BCA 3rd Semester Data Structures and Algorithms Exam 2023-2024 PDF
Full Transcript
CP312 Algorithm Design and Analysis I LECTURE 1: INTRODUCTION TO ALGORITHMS 1 Main questions What are algorithms? Why is the study of algorithms worthwhile? How do we analyze and design algorithms? 2 What are algorithms? Definition: An algorithm is a well-defined procedure consisting of a sequence o...
CP312 Algorithm Design and Analysis I LECTURE 1: INTRODUCTION TO ALGORITHMS 1 Main questions What are algorithms? Why is the study of algorithms worthwhile? How do we analyze and design algorithms? 2 What are algorithms? Definition: An algorithm is a well-defined procedure consisting of a sequence of computational steps that takes some value, or set of values, as input and produces some value, or set of values, as output. An algorithm is a tool designed to solve a particular computational problem. Examples? β¦ β¦ β¦ β¦ Sorting elements Finding the median value in a list Finding the shortest path from A to B Finding the optimal way to shop in a supermarket 3 Example: Sorting Problem: Sort a sequence of numbers in non-decreasing order Input: A sequence of numbers π = π1 , β¦ , ππ Output: A permutation π β² = π1β² , β¦ , ππβ² of π such that π1β² β€ π2β² β€ β― β€ ππβ² An algorithm for the sorting problem is a sequence of computational steps with the above input/output specifications. Ex: 8, 10, 1, 6, 2, 7, 3 β (1, 2,3,6,7,8,10) 4 Example: Majority Problem: Find the element in a list that occurs the most number of times Input: A multi-set of numbers π = π1 , β¦ , ππ Output: A number π₯ such that number of #π₯ β π > (#π¦ β π) for any π¦β π₯ An algorithm for the majority problem is a sequence of computational steps with the above input/output specifications. Ex: 1, 7, 7, 1, 7, 7, 4 β 7 5 Example: Majority We will always start with the naΓ―ve approach β¦ NaΓ―ve: The simplest (not necessarily most efficient) approach that you know for sure will give you the correct answer. What is the naΓ―ve approach for the majority problem? 1. 2. 3. List the number of unique elements π₯1 , π₯2 , β¦ , π₯π in π For each π₯π iterate over the entire list: Count the number of π₯π in π Output π₯π with the highest count How fast is this algorithm β in terms of the number of items in the list? 6 Example: Majority Questions you need to answer: Better β¦ Can you do better than naΓ―ve? β¦ How fast can the algorithm be? β¦ Is there a theoretical lower bound? (e.g., you can prove that it cannot be done better than π2 ) Worse 7 Other real-life examples Big Data: How do we manage, search, and manipulate large volumes of data on the internet? And what is the best way to do it? Networking: How do we route and find the shortest path for packets on the network while causing minimal congestion? Image Processing: How do we edit, restore, filter, analyze, and classify images? Security: How do we secure our data in storage and in transit? And what is the best way to do it? And many moreβ¦ (e.g. Electronic commerce, resource allocation, etc.) 8 Why is the study of algorithms worthwhile? Functionality Correctness Running-time β¦ Scalability Space/Memory Elegance and Simplicity Reliability 9 How do we analyze and design algorithms? Analysis: We will focus on techniques to analyze the correctness and running-time of algorithms. Design: We will look at various techniques that will help in designing algorithms, developed to solve particular computational problems. 10