In the last session, we went over some basic stack and queue concepts. Stacks and queues are abstract data types meaning that they declare an interface of functions to manipulate but not the underlying implementation. Stacks are Last in first out (lifo): the last inserted (pushed) element will be the first to be extracted (popped). A stack implementation should define two operations: stack.push(element_type x) and element_type stack.pop(). Think of a stack of dishes in a buffet. You can push new plates onto the stack but when you grab a plate from the stack, it will be the last plate that was pushed onto it. Some variants of stacks will have three functions: push(element_type x), void pop(), and element_type peek() where the role of pop() is split into a function that returns the value but does not remove that element from the stack and one that just removes the element from the stack. A queue is first-in-first-out (fifo) data structure with functions: queue.enqueue(element_type x) and element_type queue.dequeue(). The running times of these operations are wholly dependent on how the stack or queue is implemented. Typically, we like O(1) (constant-time) push, pop, enqueue, and dequeue, but that isn't always achievable if we are constrained by space or allocation requirements.
Shrunk and White of Programming When you put down that you know a certain programming language or languages on your resume, you are setting certain expectations for the interviewer. I would strongly caution against putting down "expert" in a language unless you invented or are one of the language's maintainers. You are giving your interviewer the license to quiz you on programming language lore. There are a handful of concepts that are considered "standard" knowledge for each language which go broadly beyond syntax and general semantics. These concepts commonly involve major pitfalls in a given language and the idiomatic technique for negotiating these pitfalls and writing efficient and maintainable code. Note, although the concepts are considered idiomatic, you can seldom infer them from knowledge of syntax and semantics alone. The tricky part here is that most courses that teach a particular programming language do not cover these idiomatic techniques and e...
Comments
Post a Comment