Artificial Intelligence

Bidirectional Search

Posted on

Hello people! In this post we will talk about Bidirectional Search, a powerful search strategy which can be used if you have a goal directed agent in a (possibly infinite) search space. The idea behind Bidirectional search is to run two simultaneous searches, one forward from the source state and the other backward from the […]

Array Interview Questions

Rotate matrix clockwise

Posted on

Problem statement – Given an array of N rows and N columns (square matrix), rotate the matrix by 90° in clockwise direction. Solution – This is an implementation based problem, which means that when asked in an interview, the interviewer is mainly testing your skill to write a program which follows some set of rules. […]

Array Interview Questions

Print matrix in spiral order

Posted on

Problem statement – Given a 2D array (or matrix) of N rows and M columns, print it in a spiral order. Example, for the below matrix – The output is – Solution – When an interviewer asks you this question, he/she is just testing your implementation skills. This question isn’t tough because it doesn’t have […]

Array Interview Questions

Add one to digit array

Posted on

Problem statement – Given a non-negative integer in the form of an array of digits, add one to digit array. The digits are stored such that the most significant digit is at the head of the list. Eg. – A = {1, 3, 5}, answer = {1, 3, 6} Solution – When an interviewer asks […]

Graph Theory

Adjacency List with String vertices using C++ STL

Posted on

Hello people..! This is a special extension for my discussion on Graph Theory Basics. Here, I give you the code for implementing the Adjacency List using C++ STL where each vertex is a string instead of and integer. This code has been requested many times, so I decided to create a separate page for it. […]