MySQL Query Set

1)
http://www.crazyforcode.com/mysql-query-set-5/

We have 3 tables Movie, Reviewer, Rating as shown below:
Movie ( mID, title, year, director )
There is a movie with ID number mID, a title, a release year, and a director.

Reviewer ( rID, name )
The reviewer with ID number rID has a certain name.

Rating ( rID, mID, stars, ratingDate )
The reviewer rID gave the movie mIDa number of stars rating (1-5) on a certain ratingDate.

Q1. Find the titles of all movies that have no ratings.
Q2. For all cases where the same reviewer rated the same movie twice and gave it a higher rating the second time, return the reviewer’s name and the title of the movie.

Ans 1) select title from movie where mid not in (select distinct mid from rating)

Ans 2) 
SELECT  NAME,TITLE FROM RATING AS R1,RATING AS R2,REVIEWER,MOVIE 
WHERE MOVIE.MID=R1.MID AND REVIEWER.RID=R1.RID 
AND R1.MID=R2.MID AND R1.RID = R2.RID 
AND R1.STARS < R2.STARS 
AND R1.RATINGDATE < R2.RATINGDATE 
ORDER BY R1.RATINGDATE ASC

General Algorithm Questions

1) http://javarevisited.blogspot.com/2013/03/top-15-data-structures-algorithm-interview-questions-answers-java-programming.html

2) Binary Search
1) while (low <= high) 2) mid = low + high-low/2 ; // to avoid overflow 3) Implement LRU Cache http://www.geeksforgeeks.org/implement-lru-cache/

4) Given a string “{ab}{}{{dhk}}” write a program to find if the parenthesis are balanced.