CS 210: DATA
STRUCTURES AND ALGORITHMS
Tutorial 2
- The
List ADT is to be extended with a Boolean member function, isOrdered, which determines whether the data items in the
list are in ascending order.
- Write
the function definition.
- Describe
the function in terms of Big-O.
- The
specifications of the insert method in the List ADT (static array
implementation) have been changed. Rather than inserting a new element at
a specific position, the new element will be inserted in a position
determined by the insert function such that the elements of the list are
arranged in ascending order after the insertion.
- Rewrite
the method insert (ElemenType item).
- Describe
the running time of the new insert in terms of Big-O.
- Algorithm1
does a particular task in "time" of N3, where N is
the number of elements processed. Algorithm2 does the same task in a
"time" of 3N + 1000.
- What
are the Big-O requirements of each algorithm?
- Which
algorithm is more efficient by Big-O standards?
- Under
what conditions, if any, will the "less efficient" algorithm
execute more quickly than the "more efficient" algorithm?