Skip to main content

Posts

Featured

Cache Hits Problem Code: CACHEHIT (JUNE COOKOFF 2020)

Cache Hits Problem Code: CACHEHIT (JUNE COOKOFF 2020) Quick explanation: Given an array of n integers and an integer b. We have to divide n integers into some blocks of size b. It means if we have n=5 and b=3 then array elements are {0,1,2,3,4} so we have to divide as {0,1,2} as one block and {3,4} as another block. So, this is what they mean by the machine loads array into blocks. Initially cache is empty. We have to load array elements into blocks. Next, they will give m integers . Going sequentially through m elements, we have to check if given element is in cache or not , if not we have to load that block, if it is in the block of cache then no need to load any block. When ever we are loading a block we have to remove the previous block which is present. So lets have an example to understand more easily. Let n=7, b=3 , m=6. And the m elements are 0,4,5,3,4,6. So first create blocks 0,1,2  -- block1 3,4,5  -- block2 --------- 0,1,2 6         -- block3 First given number “0” .

Latest Posts

Object Oriented Programming - Java Programming Course - Chapter 2

Writing our first java program and understanding it - Java Programming course - Chapter 1

Mo's Algorithm - Introduction