Topic 04 Basic Set ADT Solutions.pdf - Topic 4 Basic Set ADT Solutions Copyright(c 2016 2017 2018 Daniel D Suthers All rights reserved These solution

Topic 04 Basic Set ADT Solutions.pdf - Topic 4 Basic Set...

This preview shows page 1 - 2 out of 3 pages.

Topic 4, Basic Set ADT: Solutions Copyright (c) 2016, 2017, 2018 Daniel D. Suthers. All rights reserved. These solution notes may ONLY be used by students in ICS 311 Fall 2018 at the University of Hawaii. 1. (6 pts) For each of the four types of lists in the following table, what is the asymptotic worst-case running time for each dynamic set operation listed given a list of length n ? k is the key (set element) and p a position in the data structure Assume that keys are unique . Search returns a position. We don’t have to search for the item if we have a position p for it. Sorted lists are sorted in ascending order of the relation “<” Predecessor, successor, minimum and maximum are with respect to ordering of keys in the set under “<”, not necessarily the ordering of the list data structure. Grading: the shaded cells were already filled in. 0.1 point will be deducted for each unshaded boldface cell that is wrong. Unsorted, Singly Linked (no tail pointer) Sorted, Singly Linked (no tail pointer) Unsorted, Doubly Linked, Sentinel and Tail pointer Sorted, Doubly Linked, Sentinel and Tail pointer minimum() Θ(n) Θ(1) Θ(n) Θ(1) maximum() Θ(n) Θ(n) Θ(n) Θ(1) Using key (set element) k: insert(k) Θ(1) Θ(n) Θ(1) Θ(n) search(k) Θ(n) Θ(n) Θ(n) Θ(n) delete(k) Θ(n) Θ(n) Θ(n) Θ(n) successor(k) Θ(n) Θ(n) Θ(n) Θ(n) predecessor(k) Θ(n) Θ(n) Θ(n) Θ(n) Using position p (which references a linked list cell containing a key): delete(p) Θ(n) Θ(n) Θ(1) Θ(1) successor(p) Θ(n) Θ(1) Θ(n)
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read all 3 pages?

  • Fall '08
  • Barjaktarovic,M

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors