Photo AI
Last Updated Sep 27, 2025
Revision notes with simplified explanations to understand Heuristics for Problem Solving quickly and effectively.
207+ students studying
Heuristics are problem-solving techniques that use practical, experience-based methods to find solutions more quickly when traditional methods are too slow or fail to provide an exact answer. In computational contexts, heuristics help programs make efficient decisions by providing good enough solutions rather than optimal ones.
Heuristics are particularly useful in complex or large-scale problems where finding the perfect solution would take too long or require too much computational power.
Heuristics guide algorithms to make decisions based on estimates or rules of thumb rather than exhaustive searches.
Problem: Find the shortest path between two points on a grid.
FUNCTION AStar(start, goal):
OPEN_SET = {start}
CLOSED_SET = {}
g_score[start] = 0
f_score[start] = h(start)
WHILE OPEN_SET is not empty:
current = node in OPEN_SET with lowest f_score
IF current == goal THEN
RETURN reconstruct_path(current)
MOVE current from OPEN_SET to CLOSED_SET
FOR each neighbor of current:
IF neighbor in CLOSED_SET:
CONTINUE
tentative_g_score = g_score[current] + distance(current, neighbor)
IF neighbor not in OPEN_SET OR tentative_g_score < g_score[neighbor]:
g_score[neighbor] = tentative_g_score
f_score[neighbor] = g_score[neighbor] + h(neighbor)
IF neighbor not in OPEN_SET:
ADD neighbor to OPEN_SET
RETURN failure
Aspect | Benefits | Drawbacks |
---|---|---|
Efficiency | Reduces time and computational requirements. | May not always produce the optimal solution. |
Practicality | Useful for real-world problems with time constraints. | Can result in suboptimal or incorrect solutions. |
Simplicity | Easier to implement compared to exhaustive methods. | Requires careful design and tuning of the heuristic. |
Applicability | Can be adapted for different types of problems. | May be problem-specific and not generalisable. |
Scenario: A maze-solving program using a heuristic to find the shortest path.
Python Implementation:
import heapq
def heuristic(a, b):
# Manhattan distance
return abs(a[0] - b[0]) + abs(a[1] - b[1])
def a_star_search(maze, start, goal):
open_set = []
heapq.heappush(open_set, (0, start))
came_from = {}
g_score = {start: 0}
while open_set:
current = heapq.heappop(open_set)[1]
if current == goal:
return reconstruct_path(came_from, current)
for neighbor in get_neighbors(maze, current):
tentative_g_score = g_score[current] + 1 # Assuming uniform cost
if neighbor not in g_score or tentative_g_score < g_score[neighbor]:
came_from[neighbor] = current
g_score[neighbor] = tentative_g_score
f_score = tentative_g_score + heuristic(neighbor, goal)
heapq.heappush(open_set, (f_score, neighbor))
return None
def reconstruct_path(came_from, current):
path = []
while current in came_from:
path.append(current)
current = came_from[current]
path.reverse()
return path
Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!
90 flashcards
Flashcards on Heuristics for Problem Solving
Revise key concepts with interactive flashcards.
Try Computer Science Flashcards9 quizzes
Quizzes on Heuristics for Problem Solving
Test your knowledge with fun and engaging quizzes.
Try Computer Science Quizzes29 questions
Exam questions on Heuristics for Problem Solving
Boost your confidence with real exam questions.
Try Computer Science Questions27 exams created
Exam Builder on Heuristics for Problem Solving
Create custom exams across topics for better practice!
Try Computer Science exam builder12 papers
Past Papers on Heuristics for Problem Solving
Practice past papers to reinforce exam experience.
Try Computer Science Past PapersDiscover More Revision Notes Related to Heuristics for Problem Solving to Deepen Your Understanding and Improve Your Mastery
96%
114 rated
Computational Methods
Problem Decomposition with Divide and Conquer
237+ studying
195KViewsJoin 500,000+ A-Level students using SimpleStudy...
Join Thousands of A-Level Students Using SimpleStudy to Learn Smarter, Stay Organized, and Boost Their Grades with Confidence!
Report Improved Results
Recommend to friends
Students Supported
Questions answered