Amazon Interview Question for Software Engineer / Developers






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

Use SAX parser

- iPondy June 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What do you mean by "find node" ? Which criteria shall be used for finding the node ? Node name ? it's attributes ? anything else ?

- gevorgk June 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can assume any thing for example finding the contents of that node

- asd June 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@iPondy, point of this question is not to find what parser you are aware of but to find you can write some parser like code by your own.

- Anonymous June 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

can some pls clarify the question,it isn't clear

- seeker7 June 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1.Use regex like (<([a-zA-Z])+(\s)*) to find XML tags , now we can have one such regex for each type of tag like self ending tags (<([a-zA-Z])+(\s)* />), regex accounting for attritubes, comments etc.
2. Run through the input file, to find such patterns, and then create either a DOM like tree or any datas tructure to hold the XML structure.
3. A SAX parser also goes through the input file sequentially, (so does DOM parser), but the only difference is SAX is event based, so sequential parsing is justified.
4. Now we can use a Observer pattern to to let the subscriber(s) know that an event has occurred when we encounter a match.

- TheRandomGuy June 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

An alternative way is to do it the crude way, hunt for a < and then look for all cases that it could match (could be an element tag, could be a comment, element could have attributes) and so on. But I feel the previous method is more robust and lets us handle more number of cases in less amount of trouble.

- TheRandomGuy June 17, 2010 | 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