Thursday 6 October 2016

AMCAT Automata Paper 1


AMCAT-Q1 : Mooshak the mouse has been placed in a maze.There is a huge chunk of cheese somewhere in the  maze.
The maze is represented as a two-dimentional array of integers, where 0 represents  walls.1 represents paths where mooshak can move and 9 represents the huge chunk of cheese. Mooshak starts in the top-left corner at 0.0
Write a method is Path of class Maze Path to determine if Mooshak can reach the huge chunk of cheese. The input to isPath  consists of a two- dimentional array and for the maze matrix. the method  should return 1 if there is a path from Mooshak to the cheese.and 0 if not Mooshak is not allowed to leave the maze or climb on walls.
EX:8 by 8(8*8)  matrix maze where Mooshak can get the cheese.

1 0 1 1 1 0 0 1
1 0 0 0 1 1 1 1
1 0 0 0 0 0 0 0
1 0 1 0 9 0 1 1
1 1 1 0 1 0 0 1
1 0 1 0 1 1 0 1
1 0 0 0 0 1 0 1
1 1 1 1 1 1 1 1

Test Case 1:

Input: [[1,1,1,][9,1,1],[0,1,0]]
Expected return value :1
Explanation:
The piece of cheese is placed at(1,0) on the grid Mooshak can move from (0,0) to (1,0) to reach it or can move from (0,0) to (0,1) to (1,1) to (1,0)

Test case 2:
Input:
[[0,0,0],[9,1,1],[0,1,1]]
Expected return value:0

AMCAT-Q2 : The Least-Recently-Used(LRU) cache algorithm exists the element from the cache(when it's full) that was least-recently-used. After an element is requested from the cache, it should be added to the cache(if not already there) and considered the most-recently-used element in the cache.
Given the maximum size of the cache and a list of integers(to request from the cache), calculate the number of cache misses using the LRU cache algorithm. A cache miss occur when the requested integer does not exist in the cache.
Initially, the cache is empty.
The input to the function LruCountMiss shall consist of an integer max_cache_size,  an array pages and its length len.
The function should return an integer for the number of cache misses using the LRU cache algorithm.
Assume that the array pages always has pages numbered from 1 to 50.



Test Case 1:
INPUT:
3,[7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0],16
EXPECTED RETURN VALUE:
11

Test Case 2:
INPUT:
2,[2,3,1,3,2,1,4,3,2],9
EXPECTED RETURN VALUE:
8

No comments:

Post a Comment