Alpha Geek

(8)

$10/per page/Negotiable

About Alpha Geek

Levels Tought:
University

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Environmental science,Essay writing,Programming,Social Science,Statistics Hide all
Teaching Since: Apr 2017
Last Sign in: 348 Weeks Ago
Questions Answered: 9562
Tutorials Posted: 9559

Education

  • bachelor in business administration
    Polytechnic State University Sanluis
    Jan-2006 - Nov-2010

  • CPA
    Polytechnic State University
    Jan-2012 - Nov-2016

Experience

  • Professor
    Harvard Square Academy (HS2)
    Mar-2012 - Present

Category > Programming Posted 29 May 2017 My Price 5.00

Write a method called reverseFirstK that accepts an integer k and a queue of integers

Write a method called 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 example, if a queue named q stores [10, 20, 30, 40, 50, 60, 70, 80, 90], the call of reverseFirstK(4, q); should change the queue to store [40, 30, 20, 10, 50, 60, 70, 80, 90]. If k is 0 or negative, no change should be made. If the queue does not contain at least k elements, your method should throw an IllegalArgumentException. Use one queue or stack (but not both) as auxiliary storage.

 

Answers

(8)
Status NEW Posted 29 May 2017 07:05 AM My Price 5.00

-----------

Attachments

file 1496044187-Answer.docx preview (353 words )
W-----------rit-----------e a----------- me-----------tho-----------d c-----------all-----------ed -----------rev-----------ers-----------eFi-----------rst-----------K t-----------hat----------- ac-----------cep-----------ts -----------an -----------int-----------ege-----------r k----------- an-----------d a----------- qu-----------eue----------- of----------- in-----------teg-----------ers----------- as----------- pa-----------ram-----------ete-----------rs -----------and----------- re-----------ver-----------ses----------- th-----------e o-----------rde-----------r o-----------f t-----------he -----------fir-----------st -----------k e-----------lem-----------ent-----------s o-----------f t-----------he -----------que-----------ue,----------- le-----------avi-----------ng -----------the----------- ot-----------her----------- el-----------eme-----------nts----------- in----------- th-----------e s-----------ame----------- re-----------lat-----------ive----------- or-----------der-----------. F-----------or -----------exa-----------mpl-----------e, -----------if -----------a q-----------ueu-----------e n-----------ame-----------d q----------- st-----------ore-----------s [-----------10,----------- 20-----------, 3-----------0, -----------40,----------- 50-----------, 6-----------0, -----------70,----------- 80-----------, 9-----------0],----------- th-----------e c-----------all----------- of----------- re-----------ver-----------seF-----------irs-----------tK(-----------4, -----------q);----------- sh-----------oul-----------d c-----------han-----------ge -----------the----------- qu-----------eue----------- to----------- st-----------ore----------- [4-----------0, -----------30,----------- 20-----------, 1-----------0, -----------50,----------- 60-----------, 7-----------0, -----------80,----------- 90-----------]. -----------If -----------k i-----------s 0----------- or----------- ne-----------gat-----------ive-----------, n-----------o c-----------han-----------ge
Not Rated(0)