[prev] [index] [next]

Tips for Next Week's Lab (cont)

prompt$ ./rotate -r orangepurplepink
korangepurplepin
prompt$ ./rotate -l orangepurplepink
rangepurplepinko

  • Exercise 2a is a simple exercise in command line processing and string manipulation
  • To do Exercise 2b,

    1. Define LL nodes containing a single char and implement (adapt? use unchanged?) necessary LL functions
    2. Think of a strategy to re-link nodes that achieves right rotation
    3. Think of a strategy to re-link nodes that achieves left rotation
    4. Implement by functions rightRotateList() and leftRotateList()
    5. Adapt main() function from exercise 2a

  • Exercise 3: start with your solution to exercise 2b and then

    1. Think of a data-copy strategy to implement left rotation
    2. Think of a data-copy strategy to implement right rotation
    3. Re-implement rightRotateList() and leftRotateList()