Intel Interview Question for Software Engineer / Developers






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

One of the most common application of a double pointer, I have came across, is for dynamically allocating a 2d array.

for e.g. if we want a 2d array (arr[2][3]) and access it by indexing, we can use the foll. code snippet.

int **arr;
arr = (int **) malloc (2 * sizeof(int *));
for( i = 0; i < 2; i++ )
{
arr[i] = (int *) malloc (3 * sizeof(int));
}

//The code will allocate memory for arr dynamically and we can access elemts of arr by indexing...

- Jeee November 12, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

this is a simple question, if anybody asks you this he's just trying to sniff your experience in programming or just thinks you're full of it and doesn't want to waste his time with good questions.

double pointers are used to either access encapsulated data, like a 2d array, or to give a function the option to change current pointer
for exp, a LL.
void add(node **head);
in this case you can do it without the double pointer but then it's less fun.
however in BSTs you can't boast doing addNode or delNode without a double pointer.

- Nir April 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Double pointers are used in situations where the pointer itself is manipulated (apart from contents), and the changed pointer must be reflected back to the caller.

More clearly, when do we use pointers ??
When the value pointed by a pointer is changed, and the changes are reflected back to the caller.

Similarly, when the pointer itself is changed, and the changes are reflected back to the caller, we use double pointer.

Changing the pointer itself makes sense, for instance, when you have a string, or an array. When you want to run down a string, and retain the pointer position in the caller.

- Shree March 29, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Double pointers is used for:

bi-directional, non-random access.
O(1) deletion/insertion.
O(n) access.

- Jack March 29, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Are you talking about doubly link list when talking about bidirectional, non-random access?

- Anonymous January 16, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

very effective answer of double pointer

- Gaurav Vishal November 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

is pointer to a pointer called a double pointer?

- Anonymous December 09, 2014 | 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