Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Engineering Thread

1282931333460

Comments

  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭TheAmateur


    Boston wrote: »
    int index_of_largest(int unsorted_a_int*,int size)
    {
    if(size==1)
    return 0;

    index = index_of_largest(a,size-1);
    if a[size] > a[index]);

    return size;
    else
    return index;

    }

    aah, I was trying to do it without your variable "index" and I kept getting errors. Any idea why this didn't work? (technically it should... i think)
    int index_largest (double a[], int size){
        if (size == 0)
           return size;
        if (a[size-1] < a[(index_largest(a, (size-1)])
             return index_largest (a, (size-1));
        else
            return size;
    }
    
    it didn't like the
    "if (a[size-1] < a[(index_largest(a, (size-1)])"
    line.
    Also, we technically don't have to make the index_largest function recursive (she just says "it could be" in the sheet) but I get the feeling if i go in there and use iteration I'll hear "If you want the last mark you gotta use recursion in both functions" or something...:rolleyes:


  • Closed Accounts Posts: 17,163 ✭✭✭✭Boston


    Its not going to work because you're stuck in a recursive loop with no way out. When you find the largest index you need to return it, instead you make another recursive call which in turn again finds the largest index with again calls another recursion.

    The recursive swapping is easy compared to the recursive max index.


  • Registered Users, Registered Users 2 Posts: 5,699 ✭✭✭Brian


    I hate functions, and I hate recursion even more.


  • Closed Accounts Posts: 17,163 ✭✭✭✭Boston


    It's simply a new way of thinking about something. Recursive programming one of the simpler paradigms.


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭TheAmateur


    Boston wrote: »
    Its not going to work because you're stuck in a recursive loop with no way out. When you find the largest index you need to return it, instead you make another recursive call which in turn again finds the largest index with again calls another recursion.

    The recursive swapping is easy compared to the recursive max index.
    I see. Got another problem though. I get an error message at the "else" bit of your method. It goes:
    In function `int index_largest(double*, int)': 
    expected primary-expression before "else" 
    expected `;' before "else"
    
    Any idea why?


  • Advertisement
  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,303 Mod ✭✭✭✭Jonathan


    TheAmateur wrote: »
    I see. Got another problem though. I get an error message at the "else" bit of your method. It goes:
    In function `int index_largest(double*, int)': 
    expected primary-expression before "else" 
    expected `;' before "else"
    
    Any idea why?


    Look at your code closely.

    You are missing some parenthesis.
    (a[size-1] < a[(index_largest(a, (size-1)))])
    


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭TheAmateur


    Well I actually meant Boston's method, but you're absolutely right, and it compiles perfectly now. I'm not so sure anymore it does what I thought it did though, so I took it out. I'm still getting that error message with Boston's code.


  • Registered Users, Registered Users 2 Posts: 5,699 ✭✭✭Brian


    I, too, will be looking at your code closely.


  • Closed Accounts Posts: 17,163 ✭✭✭✭Boston


    I probably have a ; or } in the wrong place, I didn't intend for you to copy and past it.


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭TheAmateur


    Never said I did...:pac: but if someone were to, they'd end up with a crazy value in the first slot of their function. No idea why though. I've pretty much given up on the whole recursive index_largest function anyways, seeing as we don't specifically "have" to make it recursive.
    EDIT: Got the feckin thing. Stupid swap function was swapping a value outside the array...


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 5,699 ✭✭✭Brian


    Need some help.

    Want to share my laptop's LAN connection over Wifi to my phone. This works with my 3G modem on Mac OS X, but I want to do it in Win7 with my Halls TCD LAN. Clearly the proxy is going to present some problems. I set up an ad-hoc connection with the Network Manager to broadcast, which it does, but my phone can't connect to the internet through it.

    Giz a clue.


  • Registered Users, Registered Users 2 Posts: 7,314 ✭✭✭Nietzschean


    Check if you can reach local tcd sites on the phone, if you can then just configure the phone to use the tcd proxy, it should have settings pages for it. Though be aware you are breaking all sorts of college regulations by having a rogue access point......


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,303 Mod ✭✭✭✭Jonathan


    Two year hiatus??


  • Registered Users, Registered Users 2 Posts: 7,314 ✭✭✭Nietzschean


    Yeah good times, i figured i was doing enough nerdy things


  • Registered Users, Registered Users 2 Posts: 5,699 ✭✭✭Brian


    Nope, local pages don't work. There doesn't seem to be a proxy settings option in the S60V5 browser/network manager either.

    Hmm. Maybe if I got Metakall, it would see my computer as a TCDwifi thing...


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,303 Mod ✭✭✭✭Jonathan


    Baza210 wrote: »
    Nope, local pages don't work. There doesn't seem to be a proxy settings option in the S60V5 browser/network manager either.
    Is is under advanced options in access points manager in S60V3.


  • Registered Users, Registered Users 2 Posts: 639 ✭✭✭devinejay


    Slightly unrelated, but you've just reminded me;

    Has anyone tried/managed to get the Last FM plugin/app thing to work on TCDwifi? I would be inclined to think the NAC wouldn't let anything but the usual browsers on to use the proxy, so I never expected the app to be allowed, hence never really trying too hard.


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,303 Mod ✭✭✭✭Jonathan


    devinejay wrote: »
    Has anyone tried/managed to get the Last FM plugin/app thing to work on TCDwifi? I would be inclined to think the NAC wouldn't let anything but the usual browsers on to use the proxy, so I never expected the app to be allowed, hence never really trying too hard.
    Last.fm on what? windows or mobile phone? It works on both anyways.

    tcdproxy.tcd.ie:8080


  • Registered Users, Registered Users 2 Posts: 639 ✭✭✭devinejay


    Windows, I'll give that a go. The extents of my efforts consisted of sticking the proxy address from Chrome into the plugin, didn't work anyway!

    Cheers


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,303 Mod ✭✭✭✭Jonathan


    devinejay wrote: »
    Windows, I'll give that a go. The extents of my efforts consisted of sticking the proxy address from Chrome into the plugin, didn't work anyway!

    Cheers
    The proxy for the browsers is http://proxypac.tcd.ie/accelerated_pac_base.pac

    If you download the file and actually look at what it contains you will see this:
    // The last octet of the IP address is examined
    // Even TCD IP addresses will be pointed to proxya, odd addresses proxyb
    // PAC file format official documentation: http://wp.netscape.com./eng/mozilla/2.0/relnotes/demo/proxy-live.html
    
    // Variables:
    //              host            - the hostname extracted from the URL.
    //              url             - the full URL being accessed.
    //              ip              - IP address of client, can resolve to loopback if used from non-TCD network.
    //              lastoctet       - last octet of IP address of client.
    // removed dnsDomainIs(host, ".tcd.ie") || dm 21-5-07
    
    function FindProxyForURL(url, host)
    {
            var ip = myIpAddress();
            var lastoctet = ip.split('.');
    
            //if requested URL is local; go direct else via proxy
            if (isPlainHostName(host) ||
                dnsDomainIs(host, "localhost") ||
                dnsDomainIs(host, "127.0.0.1") ||
                url.substring(0, 5) == "news:" ||
                isInNet(host, "134.226.0.0", "255.255.0.0") ||
                isInNet(host, "10.1.0.0", "255.255.0.0") ||
                isInNet(host, "10.2.0.0", "255.255.0.0") ||
                isInNet(host, "10.5.0.0", "255.255.0.0") ||
                isInNet(host, "193.1.64.0", "255.255.248.0"))
                return "DIRECT";
            else {
                    //loadbalance even ending IP's to proxya, odd to proxyb
                    if ( (lastoctet[3] % 2) == 0 )
                            { return "PROXY proxyA.tcd.ie:8080 ; PROXY proxyB.tcd.ie:8080" ; DIRECT }
                    else    { return "PROXY proxyB.tcd.ie:8080 ; PROXY proxyA.tcd.ie:8080" ; DIRECT }
                 }
    }
    


    A different proxy is used for third party apps.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 639 ✭✭✭devinejay


    Fair nuff.

    Also, this new last.fm subscription thing is BS. I Heard about it at the end of March but when no "free trial" appearing I figured they had included us in their definition of the UK (thankfully for once). Then it don't use it for a while, come back and I've got 30 tracks left...

    Still, 3 euro a month isn't bad at all. Just an inconvenience.


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,303 Mod ✭✭✭✭Jonathan


    devinejay wrote: »
    Also, this new last.fm subscription thing is BS. I Heard about it at the end of March but when no "free trial" appearing I figured they had included us in their definition of the UK (thankfully for once). Then it don't use it for a while, come back and I've got 30 tracks left...

    I've never subbed to last.fm. I dont see any advantages.

    I'm happy with my current setup of scrobbling and listening to streams from foobar and mobber and then making funky graphs with last.fm extra stats :)


  • Registered Users, Registered Users 2 Posts: 639 ✭✭✭devinejay


    Funky indeed...


  • Registered Users, Registered Users 2 Posts: 5,699 ✭✭✭Brian


    jmccrohan wrote: »
    Is is under advanced options in access points manager in S60V3.

    Finns inte i v5.


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭TheAmateur


    Was going through the 2006-7 1e5 exam and q.4 reads
    A car of mass 500kg rounds a bend on a horizontal road at a speed of 10m/s. The radius of curvature of the bend is 40m. The fictional force (in Newtons) exerted on the car by the road is:
    a = 5000, b = 250, c = 4900, d = 1250, e = 125"
    Is that supposed to read "frictional"?
    On a more general note, anyone got any study tips for these exams?
    Also, this thread has slipped to page 3!?!
    EDIT: just realised it probably isn't frictional... there's no coefficient of friction given in the question. The question just looks the same as one he gave in a tutorial about friction stopping the car from sliding as it's going around the corner. So.... I'm guessing the answer is not C?


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,303 Mod ✭✭✭✭Jonathan


    Circular-001.gif

    So (500*(10)^2)/40 = 1250 so yea, D is correct.


  • Closed Accounts Posts: 17,163 ✭✭✭✭Boston


    Jonathan wrote: »
    Circular-001.gif

    So (500*(10)^2)/40 = 1250 so yea, C is correct.

    D is correct no?


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭TheAmateur


    Oh yeah... I meant d too... yep. Em, just out of curiosity, why would the centripetal force come from the road? And why is it "fictional"?


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,303 Mod ✭✭✭✭Jonathan


    Boston wrote: »
    D is correct no?
    Duly edited.


  • Advertisement
  • Closed Accounts Posts: 17,163 ✭✭✭✭Boston


    It's been a long time since i did mech, but afair you need to find frictional force and do up a force balancing equation.


Advertisement