mojo666's Profile User Rating: -----

Reputation: 352 Architect
Group:
Expert
Active Posts:
770 (0.42 per day)
Joined:
27-June 09
Profile Views:
11,376
Last Active:
User is offline Today, 12:32 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Mozilla
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Expert In:
Computer Science

Latest Visitors

Icon   mojo666 has not set their status

Posts I've Made

  1. In Topic: Need Help with Loop to Get Input

    Posted 24 Jul 2014

    Uhhh, where's your loop? Your program should resemble the following pseudo code

    open file
    while str is not empty
    {
         print "Enter some text:"
         read input into str
         write str to file
    }
    close file
    
    
  2. In Topic: Simple Recursion Problem

    Posted 15 Jul 2014

    Also, as written your code will either always return the negative number rather than the max or just keep recusing if it makes it that far. It might help to use variables with more meaningfull names.

    int Max(int biggest)
    {
    	int newInput=0;
    	cin>>newInput;
    	if(newInput<0)	//terminating condition
    	{return biggest;}
    	else
    	{
    		/*determine which number (newInput or biggest) needs to be passed in recursion*/
    		return Max(/*yourDecision*/);
    	}
    }
    //This code does not account for cases where the first input is negative.  You may want to adjust for that.
    
    
  3. In Topic: making a binary search in an array

    Posted 15 Jul 2014

    Binary search only works on sorted arrays. Before you can even think about doing a binary search, you need to have code that stores the data in the array in sorted order. Your code does not read any data into the array, much less sort it. You should get that part figured out first.
  4. In Topic: making a binary search in an array

    Posted 15 Jul 2014

    You ask the user to enter 10 numbers, but you don't have any code to read in those 10 numbers and store them into your array.
  5. In Topic: Binary Search - Issue w/ my while loops

    Posted 2 Jul 2014

    Quote

    So to do it properly, I'm assuming that I use the middle to eliminate half of the array, then I find the middle of what I have remaining and do the same, and repeat this until I find the correct value? So for example, if value < middle, I find the middle point between element 0 and middle, then if value is higher than the new middle, I find the middle point between the new and old middle, and continue until I find the correct value? Or is that also incorrect?


    Yep, that is how you do it. I recommend using the variables "hi", "low", and "middle". If the middle element is bigger than the number you are searching for, you set hi to middle-1 and if it is lower then you set low to middle+1. Then repeat the process by finding the middle point between hi and low. That way, you don't confuse yourself thinking about "old mid", "new mid", "old old mid", etc.

My Information

Member Title:
D.I.C Addict
Age:
30 years old
Birthday:
July 23, 1984
Gender:
Interests:
Chess, math, computers, AI
Years Programming:
6
Programming Languages:
C++, C#, VB.net, SQL, OCAML, LISP, MIPS

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Friends

Comments

mojo666 has no profile comments yet. Why not say hello?