Amazon Interview Question for Testing / Quality Assurances






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

ROPE data structure is used generally for the text editors

- Ashupriya July 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I agree, good point

- rw7026 May 12, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Ramu:

I think Linked List is not efficient because, how would you get the a particular line directly; you need to traverse the from the starting of the list to get it.

- it'sme November 14, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I was using map initially. But I changed my mind now. I think Linked List should be better. If you use map, it is easy to find paticular line. However, when you want to delete or add a line, you have to change all the line numbers afterward. Actually, when you edit in a Notepad, you usually don't use line number. You just move from the first line and sequently search until the line you want to edit. This is exactly what you do with a Linked List.

- Anonymous November 29, 2007 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

I guess, Here linked list means, double linked list. If we use double linked list then we can traverse in both directions. if we want to go to another line, then also it can movable.
wt you say?

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

Yes, doubly linked lists should work!

Also, if we are to maintain line numbers, on inserting a new line somewhere in between, we need to update the line numbers on all the lines following it. This is linear ofcourse.

We could use an index on line numbers. So we could retrieve the line in constant time from this index. However, on inserting a new line we need to update the index. This is linear again.

- khexa January 23, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I would probably design a class with following minimal properties

1. a string to represent the name of the notepad
2. a hash map with key as line number and value as the entire string.

Methods for the Notepad class:
1. edit(int line_number): this function should pull up the string from hash map based on the line number and re-write the entry.

Above proposed method is just a skeleton, there could be many more additions to it.

- Sucharita: August 18, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I would suggest that we use a linked list to store the element that is strings. Then we would also store the strings in a suffix tree. This tree not only has the words but also has the value that indicates the position of the string stored in the linked list. Thus it would become easy to search a string and also store the data.

This is a memory consuming solution but effective in actions like cut, copy, paste and also in searching in notepad.

- vijay Reddy February 10, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

will a doubly linked list work when the user just jumps back and inserts a character in between. how bout using the StringBuffer class of java to represent the entire contents

- gatech February 18, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I do not understand why one should load the whole content in a map (hashtable or tree etc). Even though it will give you time-efficiency but think of the memory requirement. Imagine you want to view a production-log file of huge size, say 4GB. Do you think you can load that in RAM. In fact Microsoft Notepad suffers this size problem.

My proposal is to trade-off this time-efficiency at the cost of handling unlimited size files. To do that, I'll keep the current cursor position in a variable. As you type, the cursor moves and the variable value increases.

Moreover to support other functionalities like, replace, insert, delete, append (similar to insert) and undo, I would like to have a data structure say, action. An 'action' might have three attributes - positionForAction, stringValue and actionType. So for invoking each method like replace, insert, delete etc you pass an action instance as method argument.

For undo, we need to store previous state for each action. One way to deal this is to store the undo action in a stack for each action. For example, if you delete char 'P' at location 1243, then create an action instance (positionForAction=1234, string='P', actionTpye=insert) and store it in a stack.

Search is another must-have feature and for that I would implement a good string pattern search algorithm such as Knuth-Morris-Pratt Algorithm.

- kg March 02, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I'd use gap buffer.

- Anonymous July 15, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

What about linked list where each node in the list stores each line of the notepad. When user inserts a new line in the middle or moves one line to some other place..we just have to change the "next" pointers

- Ramu October 01, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

i think a 2 dimensional array would be the best. In notepad we can move mouse from one position to any other position. We can map the new position to the array index using some mathematical calculation. This wont be possible in linked list....

- Anonymous January 03, 2008 | 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