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

  Calculates the product of the following sequence

Write a java code that calculates the product of the following sequence of numbers using for/loop and do/while/loop

  Palindrome is a sequence of char that reads backward forwrd

A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554, and 11611. Write an application called Palindrome.java that asks the user t..

  What are the merits and demerits of the use of mainframes

write a 200- to 300-word short-answer response to the followingwhat are the advantages and disadvantages of the use of

  Develop a java based gui application using swing that

develop a java based gui applicationusing swing that allows the user to enter charityfund informationwrite the

  Write a java program to register students for a college

Project is for designing and developing a College Registration program. Write a Java program to register students for a college

  Create a class safestack that implements a stack of strings

Create a class SafeStack that implements a stack of strings

  Create the java code for a generic class

Create the Java code for a generic class. The class should contain at least one private data member of a generic type, a constructor which initializes the private data member to the value of a passed in argument, and a getter and setter for the ge..

  What can a catch block do with the exception object

What can a catch block do with the exception object that it receives and write lines of code to create object input and output streams for the file c:\temp\mydata.out

  Java threads

This is an introductory assignment on Java synchronization. You will use Java Threads while learning more about concurrency and achieving atomicity using Java’s inbuilt mechanisms.

  Develop and test stand alone java applications

Gain practical skills in Graphical User Interface (GUI) programming by implementing an event driven application.

  Write a program to solve rsa

Write a program to solve RSA, Use either Java or "VERY DETAILED" pseudocode. Take input for p, q, e, the number to encrypt and the number to decrypt.

  Information systems to strengthen customer

Which of the following illustrates the use of information systems to strengthen customer and supplier intimacy? BPM is considered concluded when the new processes are both implemented and accepted.

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