Home » Machine Learning/Artificial Intelligence

# Hill climbing search in Artificial Intelligence

This article is all about the **hill climbing in the heuristic search which is used in the field of AI for problem-solving using search techniques**. We will learn about **what the hill climbing search is and how it works**, and also what algorithm it follows?

Submitted by Monika Sharma, on May 29, 2019

Hill climbing is a variety of Depth-First search. In this type of search (heuristic search), feedback is used to decide the next move in the state space. It is basically used for mathematical computations in the field of Artificial Intelligence.

The main **concept of hill climbing** can be understood as follows:

suppose we are climbing the hill and are present at some point. Our task is to reach the peak point of the hill. So, we look at the neighboring points where we can step. If that step takes us closer towards the peak, then we take that step, but if it takes us farther, then we do not take it. If more than two options are available to choose from, then we choose the best one which brings us closest to our goal state.

So, the strategy that we follow in the **hill-climbing algorithm** is that we look at the neighboring point, if it is at a level which is higher than our current position, then we take that step, else we do a further comparison of the other neighboring points.

## Algorithm for Hill Climbing

**Step 1:** Evaluate the current initial state. If it is the goal state, then return and quit.

**Step 2:** If the current state is not the goal state, then loop until a solution is found or there are no further operations left for comparison.

**Step 3:** Select a new state for comparison.

**Step 4:** Evaluate the new state:

- If it is the goal state, i.e. the highest peak, then quit.
- If it is better than the current state, then make it the new current state.
- If it is not better than the current state, then go to step 2.

### Limitations/problems that occur in hill climbing

**1. Local Maxima:**

It is a state which is better than all the existing neighboring states but is not the peak point of the hill.

**2. Plateau:**

A plateau is a flat area and therefore no neighboring state in the search space exists so that it is better than the current point because all of them lie on the same plane.

**3. Ridge:**

It is an area in the search space which is higher than the surrounding areas but cannot be searched in a simple move.

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.

Learn PCB Designing: PCB DESIGNING TUTORIAL