Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
NUS CS1102 Data Structures with Multiple Organization NUS CS1102 Basic Data Structures b Array b Linked List b Trees The three basic building blocks for data structures are array, linked list and trees. We combine them to implement different data structures. NUS CS1102 Mix-and-Match 1 b Array of Linked-List 3 2 1 Array of linked list can implement a graph, or a hash table with separate chaining.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
NUS CS1102 Mix-and-Match 2 b Binary Search Tree + Linked-List 5 4 8 7 1 3 9 2 You can have an augmented BST, where the successor pointer form a linked list. NUS CS1102 More Examples b Need an ADT for s enqueue(item) s dequeue(item) s peek() s printInOrder() Here is another example. Suppose we need an ADT that supports the operations of a queue plus printing the elements In some order. NUS CS1102 Use a Queue O(N log N) printInOrder () O(1) peek () O(1) dequeue () O(1) enqueue (item) If we use a queue, we can support the queue operation efficiently. But to print the items in order, we need to first sort the items in the queue, which is O(N log N) time.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/02/2011 for the course CS 3211 taught by Professor Dunnowho during the Spring '11 term at National University of Singapore.

Page1 / 6


This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online