Adobe Interview Question
Software Engineer / Developersvoid * myMalloc(int n)
{
/*f is pointing to free chunk of m byte */
void *p=f;
if(n>m) {
printf("Error: insufficient memory");
return NULL;
}
m=m-n;
f=f+n;
return p;
}
void * myMalloc(int n)
{
/*f is pointing to free chunk of m byte */
void *p=f;
if(n>m) {
printf("Error: insufficient memory");
return NULL;
}
m=m-n;
f=f+n;
return p;
}
is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
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.
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.
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.
void *f = starting_memory_location;
- mail2vcp@gmail.com September 29, 2008void* myMalloc(int n)
{
//algorithm
(1)search for the first free node which has atlest n bytes in a circular linked list pointed by f(you have to change f, so that it circulates)(at start, theres only one node in the list with bytes as total available free space for dynamic allocation)
(2)when u find the node, if its size of free bytes equals to 'n', then mark it as used. else if its size is grater then 'n'(say 'm') then split it into 2 nodes, with firat node with size 'n'(marked as allocated) and another node with size (m-n) and marked as available
(3)if u go round 1 full rotation then return NULL