Showing posts with label Graph Algorithms. Show all posts
Showing posts with label Graph Algorithms. Show all posts

Sep 8, 2009

Birthday Calendar

Implement the birthday diary calendar to keep records of all birthdays of your friends
1) what underlying data structure(s) you will use so that the memory consumption should be optimum [i.e if you have only 12 birthday entries you should not hold memory for all 365 days of the year].

2) You should be able to view the data (birthdays) with closest birthday first [i.e 7th July should come before 11 Aug].

3) How will you keep this data sorted (for question 2), everytime you insert a new birthday entry. This sorting should be as optimum as possible [mergesort etc will not be very beneficial bcoz ideally you won't have thousands or millions of birthday]

4) How will you handle 2 or N number of birthdays on same day

Given an undirected graph G(V,E), design an algo to detect whether there is a triangle in the graph?

Sep 5, 2008

Maze Searching

Given a 2-d maze of characters, find if there exists a word "Algorithms" in the maze. By exists we mean it exists in a row, a column or like snakes (diagonals prohibited though)?

By snakes, we mean like following

A . . . M S
L G . T H .
. O R I . .
Use DFS and explore the maze as and when letters are found

Jun 16, 2008

Generating Graphs

Given n nodes,

1. generate all possible directed subgraphs.
2. generate all possible undirected subgraphs.

Easier version:

Given n nodes,
1. generate all possible directed subgraphs of n nodes,
2. generate all possible undirected subgraphs of n nodes,

Apr 1, 2008

another graph problem

Find out if there is cycle in a given graph?

Mar 31, 2008

Find minimum steps required

Given a 2-d space with origin (0,0); find in how many minimum steps can a knight reach to a point (x,y) from (0,0)? Is it possible to traverse to any such point in the space from (0,0) or we have some specific conditions on x, y for such a path to exist? Prove your arguments.

Would your algorithm be still valid if traversing in x-axis direction is cheaper than traversing in y-axis direction or vice versa?

PS: a knight walks 2 units in X-axis and 1 unit in Y-axis or 2 units in Y-axis and 1 unit in X-axis in one move.