Algorithms Lec 1
Algorithms Lec 1
Introduction
Fall 2024
Mr. Ahsan Shah
About Me
Email: [email protected]
Faculty of Computer Science and Engineering
Office: M-01
• Will be using google class room for communication:
Google Classroom Code for AI: jmdnfst Google
Course TA
• Mr. ____________
• Never hesitate to contact TA or me whenever you have some problem
Course Goals
• Upon successful completion of this course, the students will be
able to Know the concepts for design and analysis of
algorithms which form the foundations of theoretical computer
science.
• Upon successful completion of this course, the students will be
able to Design and analyze the advance data structures and
algorithms.
• Upon successful completion of this course, the students will be
able to Apply majority of efficient algorithms to design and
solve most of the today’s problems.
• All individuals involved in any kind of cheating in any exam, quiz, assignment or
Course Ethics
Projects/Assignments
⚫ Deadlines are always final
⚫ No credit for late submissions
⚫ One student per assignment at maximum
⚫ Three students per project at maximum
⚫ Project Proposal Submission : 8th Week
⚫ Project Presentation : Last week
Quizzes
⚫ Announced
⚫ Unannounced
Attendance
Assignments (2) 05
Quizzes (4) 15
Term Project (1) 10
Midterm (1) 30
Final (1) 40
Total 100
Some Rules
• There is only one rule that will make the rest of the rules
– Raise your hand before asking any question and then WAIT for the
permission
– Never ever miss a class
– Never ever “sleep” in the class
– Cramming is not a good study habit.
So, Avoid it
– Never even think to use mobile phones in the class
Course Problems…Cheating
• What is cheating?
–Studying together in groups is encouraged
–Turned-in work must be completely your own.
–Copying someone else’s solution on a HW or exam is cheating
–Both “giver” and “receiver” are equally culpable
• We have to address the issue once the cheating is reported by TAs or me.
What is an Algorithm?
Types of Algorithms
• Brute Force Algorithm: It is the simplest approach for a problem. A brute force
algorithm is the first approach that comes to finding when we see a problem.
• Recursive Algorithm: A recursive algorithm is based on recursion. In this case, a
problem is broken into several sub-parts and called the same function again and
again.
• Backtracking Algorithm: The backtracking algorithm basically builds the solution by
searching among all possible solutions. Using this algorithm, we keep on building the
solution following criteria. Whenever a solution fails we trace back to the failure point
and build on the next solution and continue this process till we find the solution or all
possible solutions are looked after.
• Searching Algorithm: Searching algorithms are the ones that are used for searching
elements or groups of elements from a particular data structure. They can be of
different types based on their approach or the data structure in which the element
should be found.
• Sorting Algorithm: Sorting is arranging a group of data in a particular manner
according to the requirement. The algorithms which help in performing this function
are called sorting algorithms. Generally sorting algorithms are used to sort groups of
data in an increasing or decreasing manner.
Ghulam Ishaq Khan Institute of Engineering Sciences and Technology, Topi
CS 478: Design and Analysis of Algorithms
Types of Algorithms
• Hashing Algorithm: Hashing algorithms work similarly to the searching algorithm. But they
contain an index with a key ID. In hashing, a key is assigned to specific data.
• Divide and Conquer Algorithm: This algorithm breaks a problem into sub-problems, solves a
single sub-problem and merges the solutions together to get the final solution. It consists of the
following three steps:
• Divide
• Solve
• Combine
• Greedy Algorithm: In this type of algorithm the solution is built part by part. The solution of the
next part is built based on the immediate benefit of the next part. The one solution giving the
most benefit will be chosen as the solution for the next part.
• Dynamic Programming Algorithm: This algorithm uses the concept of using the already found
solution to avoid repetitive calculation of the same part of the problem. It divides the problem into
smaller overlapping subproblems and solves them.
• Randomized Algorithm: In the randomized algorithm we use a random number so it gives
immediate benefit. The random number helps in deciding the expected outcome.