This is a list of exam questions I've asked on past exams for my data structures class at the University of Pittsburgh.
- What is the computational complexity when iterating over a linked list *without* using an iterator? Why?
- Explain how using an iterator improves computational complexity.
- What is a circular array?
- What are 2 advantages of using a circular array for building a queue, instead of linked nodes?
- Using words and a drawing, explain what happens when you insert an item into the middle of a linked list.
- Using words and a drawing, explain what happens when you insert an item into the middle of an array list.
- Explain the behavior of a queue, including the operations a queue should be able to perform.
- In a queue implemented using a circular array, why do we need to know more than just the start and end positions to know if the queue is full?
- Explain why removing the first item in an array list is more work than removing the first item from a linked list.
- What are all of the things you would you have to do to improve the computational complexity of the size() method?
- In your own words, explain the relationship between encapsulation and abstraction.
- In the context of data structures, why is abstraction important?
- How could abstraction be dangerous? Give an example.
- What is the purpose of leaving one index empty in an array-backed implementation of a Queue? Why is this necessary?
- Using pictures, illustrate the steps that occur when an item is removed from a linked-node based queue.
- Using pictures, illustrate the steps that occur an item is added to a linked-node based queue.
- Using pictures, illustrate the steps that occur when an item is removed from an array based queue.
- Using pictures, illustrate the steps that occur an item is added to an array based queue.
- For the add(T), remove(int), and get(int) operations, what is the difference between a LinkedList and an ArrayList implementation? What must be done for each?
- Describe one situation where an ArrayList would be preferable and one situation where a LinkedList would be preferable.
- Explain some of the tradeoffs in using array-backed data structures. When are array-based structures valuable? Why do we need linked structures?
- Explain why using a "tail" property in our Linked List makes it more efficient.
- Describe two situations where you might need to use a List; one where a Linked List would be preferred, and one where an Array List would be preferred.
- What is the computational complexity of the operation add(T) in our array-based queue implementation? Why?
- Name the 3 operations that a Stack should be able to perform, and explain what they do. What is the computational complexity of each of these operations?
- Why isn’t iterating through a Linked List (using a traditional while loop or for loop) an efficient operation?
- Why is encapsulation important when designing data structures? Name a problem that could occur if your data structure is not properly encapsulated.
- Describe, using words and drawings, how a remove(int) operation occurs in a Linked List.
- Describe, using words and drawings, how a remove(int) operation occurs in an Array List.
- Why is encapsulation important when designing data structures? Using one of the data structures we discussed in class, identify a specific problem that could occur if your data structure is not properly encapsulated.
- Write code for a public int pop() method for the following IntStack class.
- Assuming you have the following code in your class, how would you implement the “public void push(Object value)” and “public Object pop()” methods for a stack?
- Given the following code, implement an Iterator with the methods public T next() and public boolean hasNext() for this Linked List.
- Implement the following ensureCapacity method for a Queue implemented with a circular array. This method should ensure that there is room in the values array.
Comments
Post a Comment