Software engineers write programs to design and develop computer software. Interviews are highly technical, so come ready to work through coding problems and math brainteasers. The specific questions you are asked will depend on what type of programming position you are looking for. Try researching a specific software discipline such as web development, application development, or system development.
Design an algorithm, which can record the largest number in an ever-upgrading sequence.
Depending on the size of the sequence, how about: 1. If the sequence is small, just scan the sequence and return the largest number 2. If the sequence is large, use a max-heap (implemented as priority_queue in C++STL for example). After each element add, add the element also to the end of the heap and do 'max-HEAPIFY' on that node to maintain the max-heap property. After each element removal, move the last element of the heap to the removed node and do 'max-heapify" on that node also maintain the max-heap property. The largest number of the whole sequence is always the first/top element. 3. If the sequence is large, can also use a set (RB tree, std::set) to store all the elements, return the max element from the set. I suspect #2 is what they expect, but just to make a point, if the sequence is really small, #1 can be better although it is dumb,
since its only trying to find the largest one, why not just sort the seqence?
Why sort the sequence? Just keep track of the largest number and compare it to the next one.