Question

Describe the Ranked Sequence ADT (give a definition, set of operations). Compare the array-based and the...

 Describe the Ranked Sequence ADT (give a definition, set of 
operations). Compare the array-based and the doubly linked list
implementation of the Ranked Sequence ADT.

Please write alot do note give me code. Just give me a indepth explination. PLease

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:------------

Ranked Sequence ADT :----------- A ranked sequence is a collection of items arranged in a linear order, where each item has a rank defining the relative ordering of that item in the sequence. Note: Stacks, queues and dequeues are restricted type of sequences which provide an access to specific items only. 
Operations (methods) on ranked sequences: 
returnItem (rank) Returns the item at the specified rank 
replaceItem (rank, newItem) Replaces the item at the specified rank with newItem 
insertItem (rank, newItem) Inserts newItem at the specified rank 
deleteItem (rank) Deletes the item at the specified rank 
size () Returns the size of the sequence 
empty () Returns true is the sequence is empty 
traverse () Processes each node in the sequence in a specified way 

Comparison the array-based and the doubly linked list implementation of the Ranked Sequence ADT.
An array-based implementation of a ranked sequence:----------- Consider array S[i] with n objects, where i is the reference to the object with rank i. Algorithm returnItem (rank): return S[rank] O(1) efficiency Algorithm replaceItem (rank, newItem): O(1) efficiency S[rank] := newItem Algorithm insertItem (rank, newItem): O(n) efficiency for i = n-1 to rank do S[i+1] := S[i] S[rank] := newItem n++ Algorithm deleteItem (rank): O(n) efficiency item := S[rank] for i = rank to n-1 do S[i] := S[i+1] n-- return item size() and empty() methods are O(1), and traverse() is O(n) method.

A doubly linked list implementation of a ranked sequence:--------------- 1. the insertItem method (cont.) public void insertItem (int rank, Object item) throws BoundaryViolationException { if (rank != size()) checkRank (rank); DLNode next = nodeAtRank (rank); DLNode prev = next.getPrev(); DLNode node = new DLNode (item, next, prev); next.setPrev(node); prev.setNext(node); size++; } The efficiency of this method is O(n/2), because of the nodeAtRank method, which in the worst case traverses the half of the sequence.

2.the deleteItem method public Object deleteItem (int rank) throws Boundary ViolationException { checkRank (rank); DLNode node = nodeAtRank(rank); DLNode next = node.getNext(); DLNode prev = node.getPrev(); prev.setNext(next); next.setPrev(prev); size - -; return node.getData(); } The efficiency of this method is O(n/2), because of the nodeAtRank method, which in the worst case traverses the half of the sequence.

Add a comment
Know the answer?
Add Answer to:
Describe the Ranked Sequence ADT (give a definition, set of operations). Compare the array-based and the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Describe the structure and pseudo-code for an array-based implementation of the vector ADT that achieves O(1) time for i...

    Describe the structure and pseudo-code for an array-based implementation of the vector ADT that achieves O(1) time for insertions and removals at rank 0, as well as insertions and removals at the end of the vector. Your implementation should also provide for a constant-time elemAtRank method.

  • Exercise 1.12. (Difficulty 2) Bubblesort and oblivious merge-sort each give a sequence of compare-exchange operations w...

    Exercise 1.12. (Difficulty 2) Bubblesort and oblivious merge-sort each give a sequence of compare-exchange operations which sorts any array A0..3]. Write down both sequences. Exercise 1.12. (Difficulty 2) Bubblesort and oblivious merge-sort each give a sequence of compare-exchange operations which sorts any array A0..3]. Write down both sequences.

  • Please help with this Java Program. Thank you! we will be implementing an Ordered List ADT....

    Please help with this Java Program. Thank you! we will be implementing an Ordered List ADT. Our goal is to implement the interface that is provided for this ADT. Notice that there are two interfaces: OrderedListADT builds on ListADT. In this homework, you'll only be responsible for the OrderedListADT. Figure 1: UML Overview 1 Requirements Create a doubly linked implementation of the OrderedListADT interface. Note that the book includes most of the source code for a singly linked implementation of...

  • In this assignment you will be implementing two Abstract Data Types (ADT) the Queue ADT and...

    In this assignment you will be implementing two Abstract Data Types (ADT) the Queue ADT and the Stack ADT. In addition, you will be using two different implementations for each ADT: Array Based Linked You will also be writing a driver to test your Queue and Stack implementations and you will be measuring the run times and memory use of each test case. You will also be adding some functionality to the TestTimes class that you created for Homework 1....

  • Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up...

    Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up for helping. True/False (11) Chapter 12 - Lists The ADT list only works for entries that are strings. The ADT list is more general than common lists and has entries that are objects of the same type. Adding entries to the end of a list does not change the positions of entries already in the list. The first entry is a list is at...

  • 8.9 Coding lab #5: create a dynamic array ADT and a singly linked list ADT. Honor Code...

    8.9 Coding lab #5: create a dynamic array ADT and a singly linked list ADT. Honor Code Your answers to this homework must be your own work.You are not allowed to share your solutions.You may not engage in any other activities that will dishonestly improve your results or dishonestly improve or damage the results of others. Plagiarism Plagiarism is when you copy words, ideas, or any other materials from another source without giving credit. Plagiarism is unacceptable in any academic environment....

  • Please write a c++ header file, class implementation file and main file that does all of...

    Please write a c++ header file, class implementation file and main file that does all of the following and meets the requirements listed below. Also include a Output of your code as to show that your program works and functions properly. EXERCISING A DOUBLY-LINKED LIST CLASS This project consists of two parts, the second of which appears below. For the first part, write a class that implements an unordered list abstract data type using a doubly-linked list with pointers to...

  • Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up...

    Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up for helping. True/False (13) Chapter 14 - A List Implementation that Links Data Adding a node to an empty chain is the same as adding a node to the beginning of a chain. Adding a node at the end of a chain of n nodes is the same as adding a node at position n. You need a temporary variable to reference nodes as...

  • Please do this in C++ Please do this in C++ Array List Operations For an array...

    Please do this in C++ Please do this in C++ Array List Operations For an array based list, (A) If the Length operation associated with an unsorted list returns 15, and we then call the Delete operation for the list, pass it a value that matches the 7th item in the list: 1). What is the index of the component that is deleted? 2). What is the index of the component that takes its place? 3). What does the Length...

  • Please Write Pseudocode or Python code! Thanks! P1. b) is the following: W1. (6 marks) Write...

    Please Write Pseudocode or Python code! Thanks! P1. b) is the following: W1. (6 marks) Write the pseudocode for removing and returning only the second element from the Stack. The top element of the Stack will remain the top element after this operation. You may assume that the Stack contains at least two items before this operation. (a) Write the algorithm as a provider implementing a Stack using a contiguous memory implementation. You can refer to the implementation given in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT