List Testing
Time limit1sMemory limit1024 MB
Design a sequence of linked-list commands (add, remove, pop, clear, size) that triggers bugs in as many of ten buggy doubly linked list implementations as possible.
- Level
Medium6 of 10
- Topics
- Linked list, Implementation, Simulation, Brute force
- Solved
- No attempts yet
Problem
Mårten has implemented a doubly linked list. Mårten is not that smart. He does not know that almost every standard library already has linked lists.
Mårten does not agree that this is silly. He thinks his own list is much more efficient than the one in the standard library. It is up to you to prove him wrong by demonstrating that efficiency is not everything. His list is broken.
Your task is to write a number of test cases that expose Mårten's bugs. Mårten has made 10 attempts at writing a linked list in total, and your test cases must bring down as many of Mårten's implementations as possible.
A test case consists of a list of commands in the following form:
storlek- ask what the size of the list is.pop_first- remove the first element of the list.pop_back- remove the last element of the list.add_first X- add the integer to the front of the list.add_back X- add the integer to the back of the list.add X Y- add the integer at position in the list.remove Y- remove the element at position in the list.clear- remove all elements of the list.
Positions in the list are zero-indexed.
Between test cases, print a line with three hyphens: ---.
Input
The problem has no input.
Output
Print a number of lines with your test cases. You may print at most 1000 lines.