Question

queues can be modeled as arrays or linked lists. describe the advantages and disadvantages of doing...

queues can be modeled as arrays or linked lists. describe the advantages and disadvantages of doing this. Focus on the operations permitted, time and space restrictions etc. Draw diagrams if necessary.

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

If the queue is implemented using array, the the time taken to enqueue an element is O(1) which is advantage. Also, the space taken is O(n) where n is the initial size of the array. Also, each time the array is completely filled, then we need to create an array of double the size and copy all the elements into the new array. So, the space is left extra and the time taken to copy the array is also O(n) which is a disadvantage. Also, the time taken to dequeue also takes O(1).

If queue is implemented using linked list, the the enqueue and dequeue take O(1) time as we have the front and tail pointer. So, we just need to adjust the pointers to insert a new element and remove an element. Also, there is no need to create a new list of double the size and copy the elements as the size of a list is infinite. Also, unlike array, no extra memory is used like in array a big part of the array is empty. That is not the case in linked list.

Add a comment
Know the answer?
Add Answer to:
queues can be modeled as arrays or linked lists. describe the advantages and disadvantages of doing...
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
  • Answer the following questions: • Compare and contrast arrays and linked-lists. What are the advantages and...

    Answer the following questions: • Compare and contrast arrays and linked-lists. What are the advantages and disadvantages of either data structure? • Describe why binary search is more effective for finding an element in the array rather than searching through it in a linear fashion. Under what circumstances can binary search work correctly?

  • Describe two approaches to implementing stacks or queues. Some advantages and disadvantages of one over the...

    Describe two approaches to implementing stacks or queues. Some advantages and disadvantages of one over the other? What it the array position of the root of a binary tree? If m is the position of the parent of a complete binary tree what is the position of the left son? State the binary search tree condition. Show how the nodes of a binary search tree Implemented by a linked list look if the following nodes are inserted sequentially: 43, 17,...

  • Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are...

    Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are stored in a linked list of Term objects (two classes: Polynomial and Term). Term objects have two data fields: coefficient and exponent, both positive integers. Polynomial will have some methods that create linked list functionality, but not all list operations are needed; include only those used by this program. Do not use a separate linked list class. The list will be non-circular. Make a...

  • This project is meant to give you experience writing linked lists and graphs. As such, you...

    This project is meant to give you experience writing linked lists and graphs. As such, you are not permitted to use arrays or any data structure library. You may, however, make use of code presented in class and posted to Blackboard. Objective Your goal for this project is to take a block of text, analyze it, and produce random sentences in the style of the original text. For example, your program, given Wizard of Oz, might produce: how quite lion...

  • Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around...

    Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around risk and threat management, fostering an environment in which objectives seem clear: manage risk, manage threat, stop attacks, identify attackers. These objectives aren't wrong, but they are fundamentally misleading.In this session we'll examine the state of the information security industry in order to understand how the current climate fails to address the true needs of the business. We'll use those lessons as a foundation...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

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