Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Is that homework?
Try to think how you would find the greatest and smallest number yourself if you were the computer and I presented the numbers one by one. Would you write them down or would you use another trick?
No it wasnt an assignment. i just did the commands of linux and was doing questions with my friends , then we thought how to do find for this question without using array. i thought of doing it with two for loops but wasnt able to chalk out. even with sort command but not getting properly. If possible , please help me
Ok, the way I would do it is have one loop that reads in the numbers one at a time: after reading each number check to see if it is larger than the largest read so far, or smaller than the the smallest so far: if it is store it. The main advantage to this approach is that you only ever have to store two numbers: regardless of how many numbers you are supposed to compare: be it 5 or 5 million.
PS. Notice that the point of the exercise is about algorithms not implementation.
Last edited by evo2; 12-16-2009 at 06:19 AM.
Reason: PS. + typo
My logic is
Take first number & equate it to variables big & small.Now take next 4 numbers one by on & if currently entered number is > big then overwrite current on big.Similiarly if current number < small then overwrite on small.This is simple & obvious.After 5 numbers have been entered you have greatest in big & minimum in small.
If you find this post useful then thank me by pressing thumbs up button.Thank you.
Last edited by sumeet inani; 12-16-2009 at 09:10 AM.