Implementation of doubly linked lists

Assignment Help Data Structure & Algorithms
Reference no: EM131849667

Self-optimizing Lists

When doing a linear search in an unsorted list of length N, the worst case run time is proportional to N, but the time it takes to find an item depends on where that item is in the list. Items near the front of the list are found quickly, while items near the end of the list are only found after close to N steps. If the same list is going to be searched many times, it would make sense to put the items that are most likely to be searched for near the front of the list, so that they can be found quickly. However, you don't necessarily know in advance which items are likely to be searched for; you have to wait and see which ones are most likely in practice. This leads to the idea of a self-optimizing list.

In a self-optimizing list, every time an item is searched for and found, that item is moved closer to the front of the list, on the theory that over time, this will keep items that are more likely to be searched for near the front of the list. There are at least two versions of this idea. In one version, when an item is found it is moved to the front of the list (unless it s already there). In the second version, when an item is found, it is swapped with the item that precedes it in the list (unless it s at the front of the list).

You will write a program that empirically tests both ideas. To run an empirical test, you should place the integers I to 100 into a list in random order. Do a large number of searches (say, one million). You should pick the numbers to be searched for using some method such that numbers have different probabilities of being picked. (Exactly how you choose the numbers is up to you, but the probabilities will have to be significantly different for you to see any effect.) Keep track of the total number of comparisons done during all of the searches. Then at the end, you can find the average number of comparisons per search.

You should perform such an empirical test for each of the two versions of self-optimizing lists, and print out the average number of comparisons per search in each case. (If you like, you could also run the test for a static list, where you don't modify the list after doing a search.) The goal is to see how well the self-optimizing list idea works, and which version gives better results.

For the lists in this program, you are required to use your own implementation of doubly linked lists. Do not use built-in Java data types such as ArrayList or LinkedList., You can use the following class for the nodes in a doubly linked list:

static class ListNode

{
int item; // The list item stored in this node.
ListNode prey; // Pointer to previous node (or null for first node).
ListNode next; // Pointer to next node (or null for last node).

}

You can add methods and/or constructors to this class, if you need them for your program.

Reference no: EM131849667

Questions Cloud

Explain the rationale for selecting matrics : McAfee recruitment team need to evaluate "how applicants, top candidates, and successful new hires discovered the vacancies for which they applied".
Contrast the strengths and weaknesses of system : Take a moment to compare and contrast the strengths and weaknesses of each system
What exactly is democracy : What exactly is democracy? Let's start with a good working definition so we can build out discussion from there.
Define government-define politics : Define government, define politics, and describe the relationship between the two. please elaborate in paragraphs
Implementation of doubly linked lists : Program - you are required to use your own implementation of doubly linked lists. Do not use built-in Java data types such as ArrayList or LinkedList
World of campaigns and elections : What has been going on lately in the world of campaigns and elections? What are your reactions?
Law in the federal government : Using a current bill, illustrate how a bill becomes a law in the federal government. Discuss how which steps the bill has already passed
Districts and proportional representation : Compare and contrast single-member districts and proportional representation (PR). How effective is each electoral system in representing
Evaluate why diversity is an issue : You are an HR representative at Delta Corporation. Your manager has asked you to analyze the company profile and address the following in 525 to 700 words.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd