Write a method reversefirstk

Assignment Help JAVA Programming
Reference no: EM13712101

I tried to answer this but nothing, if someone knows please help!

Program- Write a method reverseFirstK that accepts an integer k and a queue of integers as parameters and reverses the order of the first k elements of the queue, leaving the other elements in the same relative order.

For case, suppose a variable q stores the subsequent elements:

front [10, 20, 30, 40, 50, 60, 70, 80, 90] back

The call of reverseFirstK(4, q); should change the queue to store the following elements in this order:

front [40, 30, 20, 10, 50, 60, 70, 80, 90] back If k is 0 or negative, no change should be made to the queue. If the queue passed is null or does not contain at least k elements, your method should throw an IllegalArgumentException.

Can you provide some help with my java language project? I hope someone nice out there can help me with it.

Reference no: EM13712101

Questions Cloud

What is the average force acted on the ball : A ball hits the ground at 12m/s and bounces back at 8m/s. The ball is in contact with the ground for 0.2s. If the mass of the ball is 250g.
The total growth rate : If a firm's earnings grow from $1 to $2 over a ten year period, the total growth rate would be 100%, but the annual growth rate would be less than 10%.  True or False?  Please explain, and you must show your calculations
What sequence of characters would you push onto a stack : Hardware vendor XYZ Corp. claims that their latest computer will run 256 times faster than that of their competitor, Prunes, Inc.
What is the speed of the newly formed water drop : A rain drop of 0.25g falling at 2m/s collides with another rain drop of mass 0.5g falling at 1.5 m/s. As a result of the collision a one single water drop of 0.75g is formed.
Write a method reversefirstk : Write a method reverseFirstK that accepts an integer k and a queue of integers as parameters and reverses the order of the first k elements of the queue, leaving the other elements in the same relative order.
Explain in needed details along with relevant and applicable : Explain in needed details along with relevant and applicable examples how Behavioral Finance class helped you to further and expand your knowledge about the whole valuation concept; including different valuation models and methods?
Microcontroller assembly language programs : Write the following 8051 Microcontroller assembly language programs and simulate your programs in EDSIM 51 simulation
Printer will be fully depreciated by straight-line method : (11%) This printer will be fully depreciated by the straight-line method over its 7-year economic life, and will be sold for $60,000 at the termination of the 5-year project. The variable costs are $26 per copy, and annual fixed costs are $80,..
Give and compare the heights of the two trees : - First insert them sequentially into a binary search tree. - Next reinsert them into an empty AVL tree, restoring the AVL property after each insertion. Show the AVL tree which results after each insertion.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Objectivesto gain experience with arrays to gain

objectivesto gain experience with arrays. to gain experience with generic algorithms.documentationexplain

  Socket programming in java tcpgoal in this project we will

socket programming in java tcpgoal in this project we will develop a web server in two steps. in the end you will have

  Computes and prints the total cost of the three items

A program is required which prompts the user to enter the individual price of three different items and computes and prints the total cost of the three items as well as the average cost. Remember to add sales tax (5% or 0.05) to the total cost.

  Describe creating java programs to calculate the squares

Using a while loop, write the square of all integer numbers from 0 to 10 make the program calculate the squares

  Each instance of this class will represent one book a book

each instance of this class will represent one book. a book consists of the title of the book a string and the authors.

  Littlest rebel starring shirley temple

Compare the novel Little Women by Louisa May Alcott and the film The Littlest Rebel starring Shirley Temple. How do these two intertwine or influence each other?

  Java programming murach 4th ed 1open the ch06ex1invoice

1.open the ch06ex1invoice project. take a screenshot after you open netbeans and paste it into a word or word

  Prepare a demo program

Design, and implement a class that will be used in a program that simulates a combination lock. The lock has a circular knob with the numbers 0 through 39 marked on the edge, and it has a three-number combination, which we will call x,y,z.

  Write a statement that writes both of their values

Given an interger variable i and floating-point variable f, write a statement that writes both of their values to standard output in the following format: i=value-of-i f=value-of-f.

  To translate infix mathematical expression

Write a program in java to translate infix mathematical expression into postfix expression and a program to evaluate the postfix expression

  Write java program to accept two words as input

Write a Java program that accepts two words as input and determines if one of them is resulting from changing the order of the others' letters.

  Explain the difference between throwing an exception and

question 1. what is the difference between throwing an exception and catching an exception?question 2. how does a

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