Tuesday, July 26, 2011

Avid TV Watcher

Here is a TV avid person. He wants to spend his max time on TV. There are N channels with different program of different length and diff times. WAP so that the person can spend his max time watching TV.Precondition: If that person watches a program, he watches it completely.

Ex:
Channel1:
prog1 – 8:00- 8:30
prog2: 9:00 – 10:00
prog3: 10:15 – 12:00

channel2:
prg1 – 8:15 – 10:00
prg2: 10:30 – 12:00

So in this case max time will be if he watches:

ch2/prg1 + ch1/prg3

Design an algorithm to find the maximum number of apples you can collect ?

As This is Season of Compnies Visiting Collages & my mailbox is full of problems :D Here is Another One

A table composed of N*M cells,each having a certain quantity of apples, is given. you start from the upper-left corner. At each step you can go down or right one cell.Design an algorithm to find the maximum number of apples you can collect ,if you are moving from upper-left corner to bottom-right corner

Yuckdonald's is considering opening a series of restaurants along Quaint Valley Highway (QVH).Give an efficient algorithm to compute the maximum expected total profit subject to the given constraints.

A Reader send me this interestinmg problem some times back & he also confirmed that recently google asked it :)

Yuckdonald's is considering opening a series of restaurants along Quaint Valley Highway (QVH).The n possible locations are along a straight line, and the distances of these locations from the start of QVH are, in miles and in increasing order,m1;m2; : : : ;mn.

The constraints are as follows:

1)At each location,Yuckdonald's may open at most one restaurant. The expected profi t from opening a restaurant at location i is pi, where
pi > 0 and i = 1; 2; : : : ; n.

2)Any two restaurants should be at least k miles apart, where k is a
positive integer.

Give an efficient algorithm to compute the maximum expected total
profit subject to the given constraints.

More Info About The Problem can be found here
http://www.cs.grinnell.edu/~coahranm/csc301/f2007/hw/a8.pdf
http://www.cs.berkeley.edu/~vazirani/algorithms/chap6.pdf
http://users.eecs.northwestern.edu/~dda902/336/hw6-sol.pdf
https://groups.google.com/forum/#!topic/algogeeks/JUpjPTR494Y
http://www.solvemyproblem.net/Webed/forum/thread.asp?tid=1213

Write an algorithm that loots the maximum amount of money from row of houses.efficiently

There is a row of houses in which each house contains some amount of money.
Write an algorithm that loots the maximum amount of money from these houses.
The only restriction is that you cannot loot two houses that are directly
next to each other.

Device an algorithm that will find a circle that contains n points inside Circle ..Another Excellent Problem From Google :)

ohh Anonymous Readers are keep sending me the problems .but instead of deleting the mails from i really used to enjoy the problems because of quality of problem asked :)

Given 2*n + 3 points in 2d space, with no 3 points collinear and no 4 points lying on a circle, device an algorithm that will find a circle that contains n points inside it, n outside it and 3 on it.

House painting Problem

There are a row of houses, each house can be painted with three colors red, blue and green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. You have to paint the houses with minimum cost. How would you do it?

Note: Painting house-1 with red costs different from painting house-2 with red. The costs are different for each house and each color.

Given that you Can store integers in strings. Right an increment function in C that will increment a given integer by one

A Reader send me mail to solve this probloem :) will tryy to do it asap :)

Given two BST. Find maximum common BST. What Will Be Time Complexity can we do it in O(N) (TC for Checking Largest Commom BST) . What Will be Time Complexity if It will be the Binary Tree . Write an Efficient Algorithm

Monday, July 25, 2011

You have a list of jobs that need to be scheduled. For each job, you know when it should start and when it should end. You need to come up with an algorithm to schedule the maximum number of jobs possible."

Find The Maximum Sum in Triangle From Top to Bottom (Euler Problem) . Don't Forget to Check the Code for Triangle Which has 100s of Base :)

An Anonymous reader sent me the problem & ii posted it here
ohh but i forgot that Problem is already solved & posted few months back . so i am not giving to d same again excpet providing the link

Problem Discription

Given a triangle like the following
3
4 6
1 5 0 1.
How many nodes would you have, for 20 rows? 2. How to find the largest sum from the top of the triangle to the one of the nodes at the bottom. In other words, if you consider it as a tree, find the max sum of all paths from root to the leaf.

Thinking Process & Approach Here

This involves maths stuff rather then considering tree (it wont work check below link for detail ) or applying computer science & problem is already famous (Euler problem ) as we have to find the maximum sum in triangle we have given a big triangle which has many small triangle only thing u need to know a triangle has 3 vertexes so that you can approach :)

and a detailed description,explaination & solution you can find here

http://shashank7s.blogspot.com/2011/04/project-euler-problem-67-finding.html

let me know if i missed something or any other approach to solve it

one think that would recommands to geeks try out the recursive solution for the same problem :)