- Value of implementing data structures and code reuse. These questions are sort of ‘in your opinion’ questions and what I would be looking for is to use your knowledge of those topics and provide to me a response of a particular question. No coding required for those two questions.
- data structures: These are tried-and-true structures that are implemented in the most efficient way that has been discovered so far! Almost all big modern languages already have implementations of these structures. Most programmers know how to use them, so using them increases code clarity when someone reads the code using these structures. Some problems are uniquely suited to these structures as well. Scheduling tasks, for example, works just like a queue does, making it a perfect problem to use queues for. Using these out-of-the-box implementations also aids with code-reuse...
- Know...
- the ‘Shunting-yard algorithm’
- infix: 3 + 7 * 2 - 8 / (6 - 2)
- postfix: 3 7 2 * + 8 6 2 - / -
- steps
- add each number to the stack, one by one
- when you reach an operator, pop off the two top numbers, perform the operation, and add the result back to the stack
- there should be only one number on the stack at the end, and that's the answer to the problem
- the idea of semaphores
- the shortest path algorithm
- the structured programming movement
- make code as modular as possible so that it's clear and easy to modify
- elements: control structures, subroutines, blocks
- the ‘Shunting-yard algorithm’
Queueprinciples- Adapter design principles
- Decorator design pattern principle
ArrayListprinciplesLinkedListprinciples- Know your interfaces and what they do:
Iterator,Iterable,ListIterator,Collection,List. - Know time complexity for
Array,List,Stack,Queue.
- ArrayList and LikedList efficiencies - efficiencies for removing, adding, etc.
- Choose best collection to apply to a given situation: storing payroll calculations, program to track progress in a maze, keeping track of customers in alphabetical order, driving dispatching system like Uber.
Basically make sure you know the ins and outs of the following data structures: ArrayList, LinkedList, Queue, or Stack.
- Description: Need to create a system to allow for basic seat reservations and decorations for adding wifi.
- You're given a UML diagram where you'll need to implement a few classes.
- What you need to do is to look at the UML diagram and simply implement the methods using the decorator method.
- You will be given a sample of what your output should look like.
- You will be given a
RunMe.javafile with starter code. Go over what the Decorator classes do: - Remember to declare your main object,
FlightSeat. - Then just code up your getters and remember to instantiate the constructor for the classes extending the decorator classes.
- Call the super class (
FlightSeatDecorator) and do your modifications locally.
- Description: The given problem is about balancing parentheses, obviously you have to make sure each parentheses has its open and respective closed parentheses.
- Example: [{}], {}, ([{}]) are balanced, [{}, {, ({) are NOT.
- Using a stack you need to check if a particular string is balanced or not. Return a
trueorfalse. - Tips: perhaps a string of opening strings, like {({.
- Have a string of closing strings like })].
- What you need to do is to iterate through the tokens.
- If the tokens are starting strings then push to the stack.
- If not then see that means it is an ending string so see if that particular string matches the top of the stack.
- Work your way through the rest of the tokens.
- Return false if any of the above steps don't work.
- If the stack is empty then you know it's true, so return that.
- Conclusion: know how stacks work and know your stacks methods:
empty(),push(),pop().
- Description: Need to implement a publish/subscribe model (like YouTube, etc.) by implementing two classes.
- Will be given a UML diagram for the methods and variable for each class you need to implement. There are links to APIs you may need embedded in the specification.
- You will be given a Queue object of a particular class will need to do such things as reading and removing oldest notifications (
poll()), getting number of notifications (size()), check if two subscribers are equal. - Conclusion: pretty simple problem, know how to use poll and size methods of queue.
- Description: Implement two methods using the
Listclass. Links to the applicable Java API docs will be available. - You will do the following:
- Reverse a list in place in O(n) time, should not need to create any new lists.
- Merge two sorted lists in O(n+m) time. Same as what was done in the polynomial homework. Result should be ordered ascending.
- Need to know the following interfaces:
ListandListIteratormethods and understand what they do. - So how do you reverse a list? Possibly have two list iterators from
Listclass and iterate between both lists with one iterator starting from the end? - How do you merge a list? May need to do some comparisons. Again call list iterator from each list.
- How do you declare a
ListIteratorobj?ListIterator<E> blah = somelist.listIterator(); - Then manipulate blah to do the merge operation. You're comparing each letter in each list to see if one comes before the other in alphabet and take that one and add to result.