Ask Experts Questions for FREE Help !
Ask
    vishvendra's Avatar
    vishvendra Posts: 1, Reputation: 1
    New Member
     
    #1

    Jul 19, 2015, 01:19 AM
    Generate 10 random no. and find longest length of increasing order without using arra
    Like 23 43 45 46 58 29 30 31 15 17
    in this series there are 3 increasing series which

    23 43 45 46 58

    29 30 31

    15 17

    longest inc. series is 23 43 45 46 58 . Which 5 consequently no. in increasing order .
    AbstractJJJ's Avatar
    AbstractJJJ Posts: 1, Reputation: 1
    New Member
     
    #2

    Sep 1, 2015, 05:27 PM
    Well, you shouldn't have to store the numbers anywhere as you generate them. As you generate each number, you will keep track of 3 things.

    1) The previous number you generated.
    2) The length of the current series.
    3) The maximum length of a series encountered so far.

    If you encounter a number greater than the previously generated number than you increment the length of the current series.
    Otherwise, if the current series length is greater, we'll set the max with this new value. Then, we'll start the length of the current series over for a new series of 1.
    After that's all done, we'll set the current random number as the previous number and repeat.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Random Generate String from ArrayList without replacement in JAVA [ 0 Answers ]

I am trying to create a program that will allow users to enter a list of names. And then the program will pull from the ArrayList randomly and pull each name one at a time until all names have been used.The auction class by itself i working fine. Problem is in the Draft class. I want to take the...

Find the length of side a? [ 2 Answers ]

so there's a triangle, A= 45 degrees B= ? C= ? b=5 a=? c= 3√2

How to find the length of helix [ 3 Answers ]

A helix is defined as, x(s)=a(s), y(s)=-R(s) cos(2*pi*np*s/l), z(s)=R(s) sin(2*pi*np*s/l) where 0.le.R(s).le.Rh and is given by, R(s)=Rh where beta and gama are constants and np is the no.of turns on the helix. Find the expression for a(s) such that the tangent vector has unit length ...

Find two prime number that if multiplied generate 400 digit [ 1 Answers ]

Find two prime number that if multiplied generate 400

How do I find the length of one side [ 4 Answers ]

How do I find the length of one side if I only have one other side and the angle


View more questions Search