Skip to main content

Posts

Showing posts from March, 2018

Sample Data Structures Exam Questions for Sorting, Hash Functions, and Hash Tables

This is a list of exam questions I've asked on past exams for my data structures class at the University of Pittsburgh. Why is inheritance potentially a problem for a SortedList? Assuming a Set is built with a sorted array as its backing structure, what is the computational complexity of the remove(Object) method?  State any assumptions you make and explain your answer. Assuming a Set is built with a sorted array as its backing structure, what is the computational complexity of the contains(Object) method?  State any assumptions you make and explain your answer. Explain how the binary search algorithm works.  If no code is written, be sure to provide a detailed description.  Illustrate with an example. What is one distinct advantage of using an array-backed SortedList over a linked approach? What is one distinct advantage of using a linked approach to a SortedList over an array-backed approach? Show the steps involved in performing an insertion sort on the array [5, 3, 9,

Sample Data Structures Exam Questions for Lists, Stacks, and Queues

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