Question

Short Answer. Under what conditions are adding or removing an element in a linked structure an...

Short Answer.

Under what conditions are adding or removing an element in a linked structure an O(1) operation?

Under what conditions are adding or removing an element in an array-based structure an O(1) operation?

How does the memory usage of an array-based structure compare to a linked structure?

what structure/implementation would be the best choice for managing a collection where the order is not important, but the user needs frequent access to elements within the collection? Explain your choice.

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

ANSWER:

a) In Linked structure, adding or removing element is O (1):

  • If we have the addition and removal of element is complete at initial element pointed by HEAD hand. Or else traversal to the element to execute operation will get O (n) time in worst case.
  • Or if a indicator is there pointing to the element to wherever insertion or deletion is perform it will take O (1)

b) In array structure, as the address is continuous

  • If directory of the element is known to be inserted or delete, it determination take O (1) time (if broken up is overlooked), but the changing of element will take O (n-m) {m is the figure of elements to the right of nth element}.

c) Memory usage of linked structure is better than array structure,

  • Array structure has permanent amount and cannot be customized in program, accordingly if a reduced amount of fundamentals in attendance in group will cause consumption of recollection as memory needed is permanent before hand.
  • In connected construction the memory is owed dynamically every time new node is additional to it and deallocated when component is removed from connected structure.
  • But, at what time there is no consumption of recollection in array (by means of full size) , array has better recollection usage than linked organization as linked organization takes more memory to store pointer changeable (it can be 2x or 3x than array).

d) Array structure can be used when order is not important and the user needs frequent access to elements withing the collection as:

  • The array construction has adjacent memory arrangement and any component can be at random accessed using directory of the constituent without any other additional cost or over head metadata.
  • While in connected list there be supposed to always a traversal instrument which make to costly, and fundamentals cannot be arbitrarily admittance.
Add a comment
Know the answer?
Add Answer to:
Short Answer. Under what conditions are adding or removing an element in a linked structure an...
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
  • Creating linked list data structure Overview The purpose of this assignment is for you to write...

    Creating linked list data structure Overview The purpose of this assignment is for you to write a data structure called a Linked List, which utilizes templates (similar to Java’s generics), in order to store any type of data. In addition, the nature of a Linked List will give you some experience dealing with non-contiguous memory organization. This will also give you more experience using pointers and memory management. Pointers, memory allocation, and understand how data is stored in memory will...

  • Homework #1 – Implementing Set with a Linked List Project Objectives 1. Be able to integrate...

    Homework #1 – Implementing Set with a Linked List Project Objectives 1. Be able to integrate the knowledge of Java Generics, Collection Framework and the Linked List data structure to implement the Set ADT. Components emphasized are: • Allowing parameterized type for handling a general class of values in the collection framework; • Understanding conceptual differences between lists and sets and implementing them with methods; • Implementation of an iterator with functionality that is appropriate for the collection, namely the...

  • 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?

  • 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 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...

  • Java's LinkedList class represents a doubly-linked list. What is the Big-O behavior of its addFirstmethod for...

    Java's LinkedList class represents a doubly-linked list. What is the Big-O behavior of its addFirstmethod for a list of size N? Group of answer choices O(1) O(log N) O(N) O(N log N) Flag this Question Question 21 pts Java's ArrayList class represents a basic array. As a convenience for the user, when the capacity of the backing array is exceeded, the class handles creating a new larger array and copying over the existing items. Its add(int index, E element) method...

  • Spanish Vocabulary Helper For this assignment, we are going to work with adding and removing data...

    Spanish Vocabulary Helper For this assignment, we are going to work with adding and removing data from arrays, linear search, and File I/O. In addition, you will learn to work with parallel arrays This program will assist an English-speaking user to build their vocabulary in Spanish This program will read a file containing a list of words in English and another containing the translation of those words in Spanish. The words and corresponding translations should to be stored in two...

  • In Java. What would the methods of this class look like? StackADT.java public interface StackADT<T> {...

    In Java. What would the methods of this class look like? StackADT.java public interface StackADT<T> { /** Adds one element to the top of this stack. * @param element element to be pushed onto stack */ public void push (T element);    /** Removes and returns the top element from this stack. * @return T element removed from the top of the stack */ public T pop(); /** Returns without removing the top element of this stack. * @return T...

  • SHORT ANSWER QUESTIONS Part 1 Classes Abstraction: What is Abstraction in terms of representation? Specifically what...

    SHORT ANSWER QUESTIONS Part 1 Classes Abstraction: What is Abstraction in terms of representation? Specifically what choices does one make when creating a class that is an example of Abstraction? Encapsulation: What is encapsulation? What is information hiding? What does a public interface to a class consist of (not in the sense of actual java interfaces but what the client uses to manipulate objects of the class) What is an object of a class? What is the constructor? How do...

  • Modify the LinkedCollection class to be a SortedLinkedCollecton class and see how that effects our implementation...

    Modify the LinkedCollection class to be a SortedLinkedCollecton class and see how that effects our implementation for adding and removing items. You should reference the SortedArrayCollection class provided for how these algorithms should be implemented. What needs to change here? Is it a lot of code or not much? Include a toString method that creates and returns a string that correctly represents the current collection. Include a test driver application that demonstrates your class correctly. //--------------------------------------------------------------------------- // LinkedCollection.java // //...

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