DS&A

Data Structures and Algorithms

Exercises: ADTs and Collections

Feb 122018

Before attempting these exercises, you should read the posts about abstract data types, arrays and stacks and queues.

Exercises

  1. Find the Python code for each of the operations supported by the list, set and dictionary ADTs.
  2. Write a description of strings as an ADT; explain what kind of data a string is, and list the important operations on strings.
  3. Explain, in terms of the primitive memory operations ‘read’ and ‘write’, how the ‘get’ and ‘set’ operations on an array can be implemented.
  4. The union of two sets is a new set containing every item from the first set together with every item from the second set. In code, write a function using the operations of the set ADT to compute the union of two input sets. Write another function to compute the intersection of two sets.
  5. Explain how two stacks can be used to implement a queue.

Comments

Aston Walker16 February, 2019Finally at 1.22am 16/02/2019 I figured it out! Still unable to answer the questions, but managed to find out what >>> meant and how to input in the iPython console. I am a mature student and a grandad aged 48 and these things require some extra effort on my part. Excellent and inspirational tutorials from these blog posts and the video helped as I am now able to understand what was being demonstrated. Thanks.

New comment

Your comment will not appear until a moderator approves it.

Atom

hosted on werp.site