Arista Networks Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

This is obvious question.
1> We need to use template class.
2> API's are very general API's like push /pop/top /size.
3> I would rather like to use Vector as it has the flexibility of resizing.
4> Yes, template class generates place holder's according to datatype and so it won't be an issue.

Implementation Fairly Easy

<template typename T>
class MyStack {
private :
vector <T> stack;
int size;
T *top;
public ;
bool Push ( T data)
{ }

T Pop()
{}

T Top()
{}

int Size()
{}
};

Now these API's are fairly easy to implement.

- hprem991 May 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

M Not Sure.. Why U think there is the limitation.

For Instance, if U find it difficult to implement generics in C. U should use void pointers.. all that template or generics can do is use an Abstract layer to make things easy.. but Finally U can do in C the same thing wat C++ or java Can Do..

I can write a Code of Stack / Queue or rather even a Vector in C using void pointer..

- hprem991 May 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes; this is software and any abstractions can be derived and made available. My point was the ease of crafting code and implementation especially when objects of being interested tend to vary in sizes.

OTOH, my original response stands corrected. The reason for highlighting the last condition in the question meant to say that the age-old trick of embedding the insertion data structure into the original object would not work as it would be provide for a singular member of the original entity into stack from library aka., it does not allow the same original entity to be inserted into different stacks at the same simultaneously

- to_google. May 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes; this is software and any abstractions can be derived and made available. My point was the ease of crafting code and implementation especially when objects of being interested tend to vary in sizes.

OTOH, my original response stands corrected. The reason for highlighting the last condition in the question meant to say that the age-old trick of embedding the insertion data structure into the original object would not work as it would be provide for a singular member of the original entity into stack from library aka., it does not allow the same original entity to be inserted into different stacks at the same simultaneously

- to_google. May 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The pain came from the fact that they only use C. Things like generics/templates in Java/C++ and object features are non-existed in C, which makes this question a pain to solve during an onsite interview

- rookie May 07, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

lol

- Anshul January 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

1. Answer to this obvious
2. Use generics in java
3. Array or linked-list can be used
4. How would this condition will change anything?

- addict2050 May 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It would matter when the problem is addressed in a pure 'C' domain. In a pure 'C' env, one does not have the luxury of using template classes and generics

- to_google May 21, 2012 | Flag


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