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

Reputation: 379 Architect
Group:
Expert
Active Posts:
820 (0.36 per day)
Joined:
27-June 09
Profile Views:
13,066
Last Active:
User is offline Aug 31 2015 02:09 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: Loop and Switch conflict?

    Posted 31 Aug 2015

    Quote

    int a,b;
    cin>>a>>b;
    for(a>=1;a<=9;a++)


    You need to loop from a to b. It might help if you reorganize your loop to look more like

    int a,b,i;
    cin>>a>>b;
    for(i=a;i<=b;i++)
    {
         if(1<=i<=9){/*fill in code*/}
         else{/*fill in code*/}
    }
    
  2. In Topic: Hello. Trying to understand stuff.

    Posted 31 Aug 2015

    Quote

    So the first thing I thought about, and ended up sort of answering myself later, was: why do we need a pre-set number of bits the computer HAS to read. I thought, well, if there wasn't a set number of bits the computer wouldn't know when to stop reading bits to then process, right?


    From what I've learned about circuit design, computers don't really read a string of bits one bit at a time. Rather there are a bunch of parallel circuits that are processed simultaneously. If you can imagine a 1-bit circuit that takes multiple 1-bit inputs and outputs 1 bit, to make a 2-bit circuit we just connect 2 of the 1-bit circuits. The 1-bit inputs on each circuit pair up to make 2-bit inputs and the two 1-bit outputs are paired to make a 2-bit output. As pulses of electricity travel through this circuit, there will always be 2 bits of output even if we only care about the 1st bit. A 32-bit system is basically just 32 of these 1-bit circuits connected together to process in parallel. The computer reads 32 bits because 32 parallel circuits are producing a bit of output on every pulse.

    I don't know the intricacies of operating systems, but generally if a program is designed to run on a 32-bit system, then if a 64-bit system runs it, only half of the system will be utilized. There may also be a risk of undefined behavior with the unused half causing errors. The opposite should not be possible as the input and output will be missing half its data and quickly becomes nonsensical.
  3. In Topic: Check the values in two rows from two tables on one row

    Posted 27 Aug 2015

    If I understand what you are looking for exactly, then I think you will need 2 joins. Basically, TABLE1 has all of your data but you are trying to pivot pairs of records to be in 1 row. This is easily accomplished by joining TABLE1 to itself by FIELD1 and FIELD3.

    The result set of this join would have the following data available

    FIELD1	FIELD3	a.FIELD2	b.FIELD2
    111111	10/2/2012	1	1
    111111	10/2/2012	1	2
    111111	10/2/2012	2	1
    111111	10/2/2012	2	2
    111111	10/26/2012	3	3
    111111	10/26/2012	3	4
    111111	10/26/2012	4	3
    111111	10/26/2012	4	4
    
    


    Then you need to join this result set to TABLE2 to filter the records.


    SELECT t1a.FIELD1, t2.FIELD1, t1a.FIELD3, t2.FIELD2
    FROM TABLE1 t1a
    INNER JOIN TABLE1 t1b
    t1a.FIELD1=t1b.FIELD1 AND t1a.FIELD3=t1b.FIELD3
    INNER JOIN TABLE2 t2
    ON t2.FIELD1=t1a.FIELD2 AND t2.FIELD2=t1b.FIELD2
  4. In Topic: Challenge: Keep track of the median of a stream of integers

    Posted 27 Jul 2015

    Quote

    O(1) time and O(1) space
    .
    .
    .
    I'm pretty sure there is an easy way to do this in constant space in exact time but I haven't worked though all the details yet.


    This is only possible if by "Integer" you mean "An integer within a given range or other finite set of values". If we are reading integers of any possible value, then every integer we have already read can become the median in the future, so every integer needs to be stored.

    For cases where we do have a range, we can implement a counting algorithm as outlined below.

    Spoiler
  5. In Topic: Find max ranking value for a group of students

    Posted 24 Jul 2015

    Quote

    GROUP BY c.clustername, cty.county, cc.id, d.IRN, d.district, cc.ranking

    HAVING cc.ranking = MAX(cc.ranking)


    cc.ranking is part of the group by, so the MAX is not really doing anything as aggregate functions only aggregate records in the group. You are telling the computer to find the maximum rank of a group of records that all have the same rank. If I understand your requirements correctly, I think you need to used a subquery.

    --Instead of this
    FROM tblCareerCluster cc  INNER JOIN 
    
    --use this
    FROM (SELECT id, MAX(ranking) FROM tblCareerCluster GROUP BY id) cc INNER JOIN
    
    


    This way, you are only joining to records that have the max ranking for each id.

My Information

Member Title:
D.I.C Addict
Age:
31 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?