Design and implement a randomqueue

Assignment Help JAVA Programming
Reference no: EM131157394

Assignment:

Answer question 1, question 2, and any other 2 questions from questions 3 to 6. You must score at least 50 to pass the assignment.

1. You have learned some fundamental data structure concepts such as array, queue and priority queue, stack, list and linked list, sequence, and unordered set, and you understand the concept of interface or abstract data type that defines the set of operations supported by a data structure and the semantics, or meaning, of those operations. You can use the interface of one particular data structure to define or implement the operations of a different data structure.

a. Describe the meaning of the essential methods add(x), deleteMin(), and size() that are supported by the priority queue interface. Implement those methods using a singly-linked list.

Analyze the running time of the add(x) and deletMin() operations based on this implementation.

b. Implement the stack methods push(x) and pop() using two queues (5 marks for each method).

Analyze the running time of the push(x) and pop() operations based on this implementation.

2. Swap two adjacent elements in a list by adjusting only the links (and not the data) using

a. singly-linked list.
b. doubly-linked list.
c. skiplist.

3. Exercise 1.5. Using a USet, implement a Bag. A Bag is like a USet-it supports the add(x), remove(x), and find(x) methods-but it allows duplicate elements to be stored. The find(x) operation in a Bag returns some element (if any) that is equal to x. In addition, a Bag supports the findAll(x) operation that returns a list of all elements in the Bag that are equal to x.

4. Exercise 2.3. Design and implement a RandomQueue. This is an implementation of the Queue interface in which the remove() operation removes an element that is chosen uniformly at random among all the elements currently in the queue. (Think of a RandomQueue as a bag in which we can add elements or reach in and blindly remove some random element.) The add(x) and remove() operations in a RandomQueue should run in constant time per operation.

5. Exercise 3.12. Write a method, reverse(), that reverses the order of elements in a DLList.

6. Exercise 3.14. Design and implement a MinStack data structure that can store comparable elements and supports the stack operations push(x), pop(), and size(), as well as the min() operation, which returns the minimum value currently stored in the data structure. All operations should run in constant time.

Verified Expert

This assignment is about understanding data structure concepts and implementing basic operation on each data structure like stack, queue, doubly linked list. This is done using java programming language. report is developed in Microsoft word document.

Reference no: EM131157394

Questions Cloud

Discuss the importance of integrating sales and operations : In this lesson, we discuss the importance of integrating sales and operations. This idea of integrated management is indeed a key tenet of supply chain and operations management practices today
How did the roles of african americans change : How did the roles of African Americans change as thousands of Black soldiers began to come back to the United States? Please keep in mind that many of these solders were returning the segregated South.
Geometric distribution applies : Assume the geometric distribution applies. Use the given probability of success p to find the indicated probability.
Find the probability that the number who consider : Of men consider themselves professional baseball fans. You randomly select 10 men and ask each if he considers himself a professional baseball fan. Find the probability that the number who consider themselves baseball fans is(a) exactlyfive, (b) a..
Design and implement a randomqueue : Design and implement a RandomQueue. This is an implementation of the Queue interface in which the remove() operation removes an element that is chosen uniformly at random among all the elements currently in the queue.
Benefits and disadvantages of business analytics : Describe the benefits and disadvantages of business analytics, as well as how the organization can be proactive in addressing any disadvantages. Include at least 3 benefits and disadvantages
Audit of the financial statements of transoceanic : For purpose s of the audit of the financial statements of Transoceanic, what procedures should the auditors employ in examining the described  loans?
Financial statement disclosures : a.) For purpose s of the audit of the financial statements of Transoceanic, what procedures should the auditors employ in examining the described  loans? b.) What financial statement disclosures should the auditors expect to find with respect to th..
What is expected return for each of given investment option : what is the expected return for each of these investment options- How can you explain to your friend why the expected returns of each investment are different?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Derive the class extendedroman from the class roman

For part 'a' the source code for class Roman is attached to this assignment. You do not have to include the method decimalToRoman as you modify this class. Also, class Roman is not used in your test program.

  A client or server prepare to use udp in a java application

How does a client or server prepare to use UDP in a Java application? Are there any differences in what the client does and what the server does?

  Write a program that reads in a text file and then computes

Write a program that reads in a text file and then computes and prints a table of letter frequencies. For example, if the file is the text of "A Tale of Two Cities", found in the file at data/tales.txt , the program will print

  Develop a menu driven console java program

Review the text p.933for the use of the printf method and using a format string -  You have completed the console program for collecting statistics for the entry of student marks. We are going to extend this application so the student names and ..

  Method that reads a text file and returns a list of tokens

Write a method that reads in a text file and returns a list of the tokens (preferably alphanumeric) in that file. Write a method to print out frequency results.

  Java program that prompts the user to input an integer

Write a Java program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits.

  Write a program that keeps track of the balance

Write a program that keeps track of the balance of a savings account. The program starts by reading the initial amount (starting value) of the savings account. It then allows the account holder to perform withdrawal, deposit and check balance proc..

  Create a class with attributes length and width

Create a class with attributes length and width, each of which defaults to 1. Provide member function that calculate and the area of the rectangle. Also, provide set and get functions for the length and width attributes. The set function should verif..

  Design the static method to find the smallest number

A Given a "Complex" class with all the standard methods for complex numbers, design the static method below to find and return the smallest complex number - Design the static method to find and return the smallest complex number.

  Modify mortgagedisplaygui.java to implement actionlistener

Interrogate the ActionEvent object and determine the source of the action.

  Perform a unit test of the shoutbox

Perform a unit test of the MyClone to test all getters and setters and methods - Perform a unit test of the ShoutBox to test all methods.

  Create a java class named headphone

Create a Java class named HeadPhone to represent a headphone set. The class contains: ? Three constants named LOW, MEDIUM and HIGH with values of 1, 2 and 3 to denote the headphone volume.

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