Adobe Interview Question for Interns


Country: United States




Comment hidden because of low score. Click to expand.
3
of 3 vote

"SPLAY TREES"--these could be the best DS that provide similar behaviour as the cache.

They are designed to provide a faster access to the same piece of data for the second time. They achieve this by there self-balancing nature.

- peechus July 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i think linked list is best option to act as a "cache" .. because we need to traverse for a particular object in cache may be in forward or in backward direction with respect to current position ... this cant be used effectively in the stack or queue (even in a circular queue)... maintaining linked list is also very easier thing ... that's why i think a "double circular" might be a best option ...

- Rajesh July 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Awesome! You never seem to pick the second best option. Not knowing the scenarios (and the terms) has its advantages, I guess.

- Anonymous July 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

What about hashed doubly link list?

- shsf July 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A scenario for using replicated local cache is when the cache server is remote/ distributed/ shared. In that case, if we fetch same data item many times in a program, we could think about caching it in local memory/ heap.

In java, a data structure for replicated cache would be Map.

import java.util.Date;
import java.util.Map;

// distributed, remote cache 
class RealCache<K,V> {
  V v;
  public V get(K k) {
    return v;
  }
  
  public void add(K k,V v) {
    // ... real cache implementation ...
  }
}

// local in-vm cache
class CacheValue<V> {
  V v;
  Date localCache = new Date();
}

class LCache<K,V> {
  RealCache<K,V> rc;
  Map<K,CacheValue<V>> map;
  static Long msecToCacheFor;

  public V get(K k) {
    Date now = new Date();
    CacheValue<V> vc = map.get(k);
    if ( vc != null && vc.localCache.getTime()-now.getTime() < msecToCacheFor ) {
      return vc.v;
    }
    else {
      if ( vc != null ) map.remove(k);
      V v = rc.get(k);
      if ( v != null ) {
        // add it to local cache
        map.put(k, new CacheValue<V>());
      }
      return v;
    }
  }
  
  public void add(K k, V v) {
    rc.add(k, v);
  }

}

- coder July 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A "Perfect Hash table" would do the lookup in O(1) time!...
which is similar to fast lookup in cache memory!...

- Anonymous July 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

doubly linked list

- neeraj August 02, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

cant we use optimal binary search trees?

- Vishal August 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

What do you mean by "replicated as cache"?

- sfsh July 07, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More