Question

Hello, I need help with following question; "You want to search a list for a key...

Hello,

I need help with following question; "You want to search a list for a key and return the keys of the two elements that come before it and the keys of the two elements the come after it. Which would be the most appropriate linked list methods to implement this application?  double linked list or circular linked list or with header and trailer nodes?

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

The most appropriate data structure is double linked list. This is because using double linked list, we can go to the previous and next nodes in constant time which is not possible in circular linked list or with header and trailer nodes.

In this case, we can get the nodes using something like:

previous two nodes: node.previous, node.previous.previous

next two nodes: node.next, node.next.next

Add a comment
Know the answer?
Add Answer to:
Hello, I need help with following question; "You want to search a list for a key...
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
  • Imagine that we need to write a (key, value) dictionary for an application, with the requirements;...

    Imagine that we need to write a (key, value) dictionary for an application, with the requirements; The application needs to find a range of keys between two values x and y often, so this operation must be fast. The same for finding the smallest key. Lookup of a key must be O(log n) or better. Which data structure is probably the best choice? a hash table an unsorted array a balanced search tree a heap a linked list

  • IN C ONLY PLZ (read the instruction carefully plz) You will implement the following functions: List...

    IN C ONLY PLZ (read the instruction carefully plz) You will implement the following functions: List * initIntegerList( ) // Return empty list int insertAtHead(int k, List*) // Insert k at head int insertAtTail(int k, List*) // Insert k at tail int removeHead(List *) // Remove head and return its key int getListSize(List *) // Return number of elements in list void printHead(List *) // Print key in head void moveHeadToTail(List *) // Move key at head to tail This...

  • I need help with C++. I want to create a function that will remove all target...

    I need help with C++. I want to create a function that will remove all target nodes in a single linked list.

  • *Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods...

    *Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods that has the following generic methods: (1) Write the following method that returns a new ArrayList. The new list contains the nonduplicate (i.e., distinct) elements from the original list. public static ArrayList removeDuplicates(ArrayList list) (2) Write the following method that shuffles an ArrayList. It should do this specifically by swapping two indexes determined by the use of the random class (use Random rand =...

  • Help will be highly rated and gratefully appreciated. Stuck with this question: I have a linked...

    Help will be highly rated and gratefully appreciated. Stuck with this question: I have a linked list that stores string at each node. Now I need help with these: 1. public String findSmallestAndRemove() The findSmallestAndRemove method should search the smallest string (using compareTo method of the String class), and removes all of such smallest strings in the linked list, and return the smallest string. It should return null if the linked list is empty. 2. public int countHowManyStringsWithGivenLength(int length) The...

  • C++ Linked List Implementation Motivation As we discussed in class, the data structures that you use...

    C++ Linked List Implementation Motivation As we discussed in class, the data structures that you use to implement your program can have a profound impact on it's overall performance. A poorly written program will often need much more RAM and CPU time then a well-written implementation. One of the most basic data structure questions revolves around the difference between an array and a linked list. After you finish this assignment you should have a firm understanding of their operation. Problem...

  • Could someone please summarize the following for my programming class? They are study questions for java...

    Could someone please summarize the following for my programming class? They are study questions for java What an association list is. How to test if an association list is empty. How to find the value associated with a key in an association list. How to add a key-value pair to an association list. How to delete a key-value pair from an association list. How efficient an association list is (using O notation). What a circular list is. What a circular...

  • Hello I need help with this question and I want the correct answer for this question...

    Hello I need help with this question and I want the correct answer for this question : The question is as the following Explain what “saturation arithmetic” is. Why is it important to use in digital signal processing applications?

  • C++ ONLY PLEASE. CAN I GET SOME HELP WRITING THIS HEADER FILE? I MAINLY WANT TO...

    C++ ONLY PLEASE. CAN I GET SOME HELP WRITING THIS HEADER FILE? I MAINLY WANT TO KNOW HOW I WOULD WRITE IT WITH A TEMPLATE. PLEASE AND THANKS IN ADVANCE. **************LinkedList.h requirements************************ linked list Class EXTRA CREDIT OPPORTUNITY: Create the LinkedList class as a template class for 5 extra credit points!!! private memebers Create a structure called ListNode, which should hold a Dinosaur and a pointer to the next ListNode ListNode pointer called head – will eventually point to the...

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

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