+ 1

max and min value of random number generated linked list in C++

i need to find the min and max value if a singly linked list with random # generator

27th Nov 2021, 7:54 PM
Mikayla Chandler
Mikayla Chandler - avatar
4 ответов
+ 8
Mikayla Chandler , before we are going to help you, please present your attempt here. if you haven't done a try by yourself so far, please do so. create your code in playground and post the link to it here. please also provide a proper task description with sample of input and output. thanks!
27th Nov 2021, 8:03 PM
Lothar
Lothar - avatar
+ 3
Mikayla Chandler Assuming your list has been generated and you only need to find min & max, you could do the following. Let's call your list/array -> arr Create 2 variables -> min, max and assign them a value of arr[0], which is equal to the first item in the list You could then create a loop which inspects each item in the list. If the item is smaller than min, re-assign the value of min to the new item. Do the same with max if the item is larger than the value of max When you finish the loop, min will contain the smallest number & max will contain the largest number print out your 2 values
27th Nov 2021, 11:13 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Mikayla Chandler Thanks 😁👍& well done!
29th Nov 2021, 5:39 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
thank you all for your help i will post the code since i made an A on the project
15th Dec 2021, 3:44 PM
Mikayla Chandler
Mikayla Chandler - avatar