Apple Interview Question for Software Engineer / Developers






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

take care of overflow and underflow condition by checking front and rear pointers

- Anonymous January 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Stupid question...and same the answers...How can you check if an array is circular??
The question is asking for a queue using an array and you all implement it using linked list, why?

- jayram singh June 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Keep adding elements to the array/Queue until its full

[1,4,6,7] front =0, rear=3

2. When full, delete one element and add a new element

[4,6,7,8(this is the 0th index if circular)] front =1, rear=0

3. If now, the rear index < front index, Queue is circular

rear =0 < front =1

- Mayank Jain August 23, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 0 vote

{
good
}

- Anonymous September 14, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Have a start_index and end_index. Insert at end_index and retrieve data at start_index. Increment start_index at every retrieval and increment end_index at every insertion.

Note: set end_index = end_index % (size of array) so that it implements the wrap around and also makes sure that end_index does not overflow the size of int.

- Neo Rulez October 20, 2007 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

For Circular Queue

Have 2 pointers rear and front.
count=no of elements
For Insertion :
rear = (rear + 1) mod capacity
count++

For Deletion
front = (front+1) mode capacity
count--

- Anon January 08, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

wonderful ! @ Anon
have some

- Anonymous October 02, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

take care of overflow and underflow condition by checking front and rear pointers

- Anonymous January 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

//queue using array
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define SIZE 5
int i,rear,front,item,s[SIZE];
void insert(int item,int s[]);
void del(int s[]);
void display(int s[]);
void main()
{
int ch;
clrscr();

front=0;
rear=-1;
do
{
printf("\n\n 1.INSERTION \n 2.DELETION \n 3.EXIT \n");
printf("\nENTER YOUR CHOICE : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\n\t INSERTION \n");
if(rear>=SIZE-1)
{
printf("\t\nQUEUE IS FULL\n");
}
else
{
printf("\nENTER AN ELEMENT : ");
scanf("%d",&item);
insert(item,s);
}
display(s);
break;
case 2:
printf("\n\t DELETION \n");
if(front>rear)
{
printf("\t\nQUEUE IS EMPTY\n");
}
else
{
del(s);
}
display(s);
break;
}
}while(ch!=3);
getch();
}
void insert(int item,int s[])
{
if(rear<SIZE)
{
rear=rear+1;
s[rear]=item;
}
}
void del(int s[])
{
int i;
item=s[front];
for(i=0;i<=rear;i++)
s[i]=s[i+1];
rear--;
printf("\n DELETED ELEMENT IS %d\n\n",item);
}

void display(int s[])
{
printf("\n");
for(i=front;i<=rear;i++)
{
printf(" \t %d",s[i]);
}
}

- JITENDER RATHORE February 16, 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