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

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

  • ***JAVA: Please make "Thing" movies. Objective In this assignment, you are asked to implement a bag...

    ***JAVA: Please make "Thing" movies. Objective In this assignment, you are asked to implement a bag collection using a linked list and, in order to focus on the linked list implementation details, we will implement the collection to store only one type of object of your choice (i.e., not generic). You can use the object you created for program #2 IMPORTANT: You may not use the LinkedList class from the java library. Instead, you must implement your own linked list...

  • Answer the question: "what is a system?" It can be as short as one page or...

    Answer the question: "what is a system?" It can be as short as one page or as long as 3 pages. What is a System? The term “system” originates from the Greek term syst¯ema, which means to “place together.” Multiple business and engineering domains have definitions of a system. This text defines a system as: System An integrated set of interoperable elements, each with explicitly specified and bounded capabilities, working synergistically to perform value-added processing to enable a User to...

  • JAVA Lab Create a class called ArrayBasedStack. Declare the following variables: • data: references an array...

    JAVA Lab Create a class called ArrayBasedStack. Declare the following variables: • data: references an array storing elements in the list • topOfStack: an int value representing the location of the stack top in the array • INITIAL_CAPACITY: the default capacity of the stack public class ArrayBasedStack <E> { private E[] data; private int topOfStack; private static final int INITIAL_CAPACITY = 5; } Add a constructor that will initialize the stack with a user-defined initial capacity. The top of the...

  • JAVA 3 LECTURE REVIEW PLEASE NEED ANSWERS ASAP. DUE IN AN HOUR!!! Question 12 points The...

    JAVA 3 LECTURE REVIEW PLEASE NEED ANSWERS ASAP. DUE IN AN HOUR!!! Question 12 points The best-case performance for a shell sort is: --- O(1) O(n2)   O(n) O(n log n)   Signaler cette question Question 22 points The best-case performance for an array of n items using insertion sort is: --- O(n2)   O(n) O(1) there is no best-case Signaler cette question Question 3 2 points A recursive method that processes a chain of linked nodes --- uses the first node 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