Open Side Menu Go to the Top
Register
Programming homework and newbie help thread Programming homework and newbie help thread

10-17-2015 , 10:43 PM
I'm hoping that's what intern-level interview questions are like, seeing as how entry level position questions in these parts amount to 'make a person class, make a calendar/planner class'
Programming homework and newbie help thread Quote
10-19-2015 , 08:02 PM
CyberShark passes.

Others go make a datagrid.
Programming homework and newbie help thread Quote
10-23-2015 , 06:23 PM
general data structures real use question:

as we're learning about various abstract data types, it seems like most of them are best suited to things such as, say, operating system operations or perhaps situations that mimic real life, like a queue to buy concert tickets online or log on to a full server.

Are there other real world applications for some of these (real world in this case meaning the business world) that I'm not thinking of?
Programming homework and newbie help thread Quote
10-23-2015 , 10:51 PM
could you vague that up a bit?
Programming homework and newbie help thread Quote
10-24-2015 , 04:32 AM
Quote:
Originally Posted by Roonil Wazlib
general data structures real use question:

as we're learning about various abstract data types, it seems like most of them are best suited to things such as, say, operating system operations or perhaps situations that mimic real life, like a queue to buy concert tickets online or log on to a full server.

Are there other real world applications for some of these (real world in this case meaning the business world) that I'm not thinking of?
Using a queue as an example, the first in/first out (FIFO) nature of this data structure lends itself to using it in satisfying various programming requirements that arise. Basically it provides an organized and consistent way that one programming entity be it an object, thread, function, middleware layer, OS layer, etc. to communicate with another programming entity. I guess the take away for you would be that you will encounter programming requirements where particular data structures will be necessary and helpful in fulfilling. Think in the abstract with these is my advice.
Programming homework and newbie help thread Quote
10-25-2015 , 08:47 AM
Quote:
Originally Posted by Wolfram
could you vague that up a bit?
Well I am talking about abstract data types

Quote:
Originally Posted by adios
Using a queue as an example, the first in/first out (FIFO) nature of this data structure lends itself to using it in satisfying various programming requirements that arise. Basically it provides an organized and consistent way that one programming entity be it an object, thread, function, middleware layer, OS layer, etc. to communicate with another programming entity. I guess the take away for you would be that you will encounter programming requirements where particular data structures will be necessary and helpful in fulfilling. Think in the abstract with these is my advice.
Is it usually pretty obvious then what the preferred solution should be?

Like if I'm writing software that handles ticket requests for a concert company, I clearly want the first order to be the first one processed, not the last one.
Programming homework and newbie help thread Quote
10-25-2015 , 10:03 AM
Roonil Wazlib,

I haven't started studying data structures and algorithms in depth yet, but I studied them a little bit in an Operating Systems class in the context of process scheduling in multi-programming environments where ideally a process is running at all times. Algorithms covered included first come first serve, shortest job first, and round robin. In this context, they each had pros on cons, so I think it's essentially a case by case basis, and in many cases you may have multiple candidates for algorithms and data structures to use.

I haven't gotten deep into the programming and computer science aspects of my studies at uni yet though, being still primarily in the networking fields, so I don't know a lot about data structures and algorithms.
Programming homework and newbie help thread Quote
10-26-2015 , 12:50 AM
What's important isn't specific data structures but rather thinking about how to model things in a computer sciencey way. "How should I implement some sort of FIFO queue of objects" is a solved problem. If I want to use one in C# and don't know what it is, 5 seconds of Googling "C# FIFO queue" will reveal System.Collections.Queue. It's then just an abstraction to me and I don't particularly care how it works. This doesn't mean that learning about data structures is a waste of time however - being familiar with them enables you to break complicated systems down into component parts.

In the example of a ticketing system, that isn't at heart a complicated system and it closely models an actual real-world queue. For something slightly more complex, suppose you have a web app where people can choose video elements and your app renders them into a video with subtitles (something like xtranormal). Suppose the video rendering turns out to be computationally expensive. A naive step 1, step 2, step 3 way of doing things could result in a bottleneck where people wait for their video to render. In order to reduce bottlenecking, you might implement a FIFO queue with a callback and, while that is processing, get the user to write in their subtitles for each sequence. That's a situation where the need for a queue might not be so obvious on first glance. So while you're right that the answer to "I need some sort of queue structure, I should use a queue" it's rarely so clear that an app should be structured a certain way as it is in the example of ticketing. The heavy lifting is figuring out the structure.
Programming homework and newbie help thread Quote
10-26-2015 , 11:36 AM
Quote:
This doesn't mean that learning about data structures is a waste of time however
please don't think this is what I'm trying to say. I think it's a very interesting topic, I'm just trying to convey that I'm not 100% clear on what the real world uses are, aside from various OS functions which I'll probably never work on.

I suppose you all get tired of hearing it from me, but thanks as usual for all the great responses.
Programming homework and newbie help thread Quote
10-26-2015 , 02:06 PM
learning them and making them besides teaching you what they are, also helps you learn how to program stuff. So while you may never implement your own queue in the real world, you probably will need to understand polymorphism and linked lists and interfaces and all the stuff you need to know in order to make those data structures and you will I assume use that stuff frequently for all kinds of things.
Programming homework and newbie help thread Quote
10-26-2015 , 08:20 PM
Quote:
Originally Posted by Roonil Wazlib
Well I am talking about abstract data types



Is it usually pretty obvious then what the preferred solution should be?

Like if I'm writing software that handles ticket requests for a concert company, I clearly want the first order to be the first one processed, not the last one.
Chris gave a good answer, can't add much to that. They come in handy in multi-threaded implementations.

This is from a clowntable post that might need a worker thread implementing a queue:
Quote:
I'm also losing the occasional tweet because write to disk can't keep up with the incoming stream. Didn't have the issue when writing to the internal SSD, the USB drive might be a tad too slow. It's something I might investigate (pretty sure I could squeeze out some extra trickery) but for now dropping a couple of tweets per day is fine with me.
Have a separate worker thread to manage a queue that actually does the system calls to write the data to disk, USB drive, whatever. Yeah the queue can back up but there is almost certainly enough idle time that when nothing else is happening the worker thread can empty the queue. I am just guessing at whether or not this is feasible with clowntable's program but this is a classic way queues are used. Of course you'll have to make adding entries to the queue thread safe but that isn't too hard.

Last edited by adios; 10-26-2015 at 08:35 PM.
Programming homework and newbie help thread Quote
10-26-2015 , 11:47 PM
About the only thing I remember from SICP is that computers are just layers of abstractions. At the base-level, you have a bunch of wires that take input and give output, you can call these queues.

At the higher level, you wrap this is a black box and call it Q, call it when you need to then to.

You can then combine these Qs together and you end up with a map.

You then combines these maps into M.

Take these Ms and you can then create an object.

Take these objects and combine them together, and you have a system of objects.

Take these objects, combine them, and call them O.

take these Os and...
Programming homework and newbie help thread Quote
10-27-2015 , 05:41 AM
Quote:
Originally Posted by daveT
About the only thing I remember from SICP is that computers are just layers of abstractions. At the base-level, you have a bunch of wirestransistors that take input and give output, you can call these queuescircuits.
Quote:
At the higher level, you wrap this is a black box and call it Qa sequential machine, calluse it when you need to then to.
Quote:
You can then combine these Qs together use this as an abstraction to define a system and you end up with a map flexible tool that you can create among other things a map.

You then combines these maps into M.

Take these Ms and you can then create an object.

Take these objects and combine them together, and you have a system of objects.

Take these objects, combine them, and call them O.

take these Os and...

...
Programming homework and newbie help thread Quote
10-27-2015 , 10:04 AM
He did say "abstract."

But yes, pay attention to the edits.
Programming homework and newbie help thread Quote
10-27-2015 , 02:58 PM
Speaking of abstract vs. concrete, I strongly recommend Code: The Hidden Language of Computer Hardware and Software by Charles Petzold.

It starts off simple with switches and explains how switches can be combined into relays (essentially mechanical versions of transitors); how relays can be combined into logic gates (AND, OR, XOR, etc.); how logic gates can be combined into circuits that can add, subtract, multiply and divide (ALUs) and circuits that store information (RAM); and how these components can be combined into a simple computer with switches for inputs and light bulbs for outputs. Along the way, he also touches on Morse code, Braille, barcodes, machine language, 86x assembly language, high level languages, ASCII, simple operating systems, and computer graphics, all within 400 pages.

It's simply one of the best books on any subject that I have read in a while. And for me it was really helpful to start from the bottom and build up each layer of complexity. Modern computers so often just seem to work like magic, so it can be a little mind-blowing to see how everything they do results from incredibly simple operations being performed over and over again according to specific patterns and at incredible speeds.

This may have been easier to grasp with older computers when you typed a command and then had time to think about what was going on inside the computer while it calculated the output. I remember my dad showing me how to write a simple BASIC program on his monochrome luggable IBM-compatible in the mid 80s. Those machines seem much simpler than the ones we use today, although they are still exceedingly complicated.

At any rate, gaining some understanding of how the complex behavior of computers emerges from layer upon layer of simple rules and instructions makes it easier to think about how the same thing can happen with neurons. (I also think it was helpful to read this book before trying to learn C.)
Programming homework and newbie help thread Quote
10-27-2015 , 07:50 PM
working with java and oracle sql, use a file to input data to the database and ran into an issue with mismatched date formats.

one is of the format "day-month-year", the other is "month/day/year". (month being 3 letter text in each)

I'm supposed to be looping over this, so whatever I write I assume should be able to handle either. I tried to_date, but that didn't work so well.

I'm getting a sql error of "a non-numeric character was found where a numeric was expected" when I loop over the wonky-formatted one.

I've extracted each field into its own variable, like int for any Numbers and String for any names (using single quote wrappers of course).

Suppose there could be a way to verify in java if a string is in a certain format, but I thought to_date would handle this, which it doesn't.
Programming homework and newbie help thread Quote
10-27-2015 , 09:04 PM
Data integrity should be verified before you try to insert it in a database. Convert the input to a date in Java then insert it. I'm not sure if you're using some API and can insert a date directly. A good portable date format to use if you need to convert it back to a string is yyyy-MM-dd, which works with both US and UK locales and is understood by pretty much everything.
Programming homework and newbie help thread Quote
10-27-2015 , 09:24 PM
The db I'm putting it into prefers dd-mon-yyyy. I'll have to see if there's a Java date format similar to that. Thanks for the tip!

*edit*

took the lowbrow way out and just yanked out the data I need and rearranged it.

reusable? No way in hell!

Last edited by Roonil Wazlib; 10-27-2015 at 09:51 PM.
Programming homework and newbie help thread Quote
10-27-2015 , 09:55 PM
If Oracle, I'm guessing there is a CAST() function you can use that will convert the date for you.

In fact, since I know the magic word, I managed to find this: http://stackoverflow.com/questions/1...n-yy-to-yyyymm

I'm thinking this should work directly in your Java code (please use paramaterized values!), but if not, you'd have to do some other silly trick to get it to work, but I can't imagine how Oracle can't do this. Let me know and I'll give you a few ideas.
Programming homework and newbie help thread Quote
10-28-2015 , 04:03 PM
Does anyone here know MIPS assembly and the PIC32?

I'm trying to write a program in assembly that gets the time between 2 presses of a button. I have zero ****ing clue how to do this and I've spent the last several hours googling. I'd post on the microchip forums but they are admin approved

I've been reading the reference manuals, but its like gibberish to me. Ive found some stuff about the registers that are associated with I/O (TRIS, PORT, LAT), but I dont understand it. If the button is on pin 4 of my board, does that corespond to TRIS4, PORT4, LAT4? In the spec sheet of the actual board tho it says the pic32 signal is SOSCO/T1CK/CN0/RC14, but wtf is that, I don't find anything about any of that in the pic32 ref manual

How do I go from being able to read those registers and see when a button has been pressed, to getting a time at press? I've seen some **** about ICxBUF but I don't understand it at all.

It's a special project, so its nothing thats covered in our book or lectured on by the teacher. I havent even been able to find a good resource that explains anything, so even if you just know of one that would be a tremendous help.

thanks!!
Programming homework and newbie help thread Quote
10-29-2015 , 08:10 AM
Quote:
Originally Posted by Alobar
Does anyone here know MIPS assembly and the PIC32?

I'm trying to write a program in assembly that gets the time between 2 presses of a button. I have zero ****ing clue how to do this and I've spent the last several hours googling. I'd post on the microchip forums but they are admin approved

I've been reading the reference manuals, but its like gibberish to me. Ive found some stuff about the registers that are associated with I/O (TRIS, PORT, LAT), but I dont understand it. If the button is on pin 4 of my board, does that corespond to TRIS4, PORT4, LAT4? In the spec sheet of the actual board tho it says the pic32 signal is SOSCO/T1CK/CN0/RC14, but wtf is that, I don't find anything about any of that in the pic32 ref manual

How do I go from being able to read those registers and see when a button has been pressed, to getting a time at press? I've seen some **** about ICxBUF but I don't understand it at all.

It's a special project, so its nothing thats covered in our book or lectured on by the teacher. I havent even been able to find a good resource that explains anything, so even if you just know of one that would be a tremendous help.

thanks!!
Depends on clock speeds of the processor for one. Two, if you are running on an OS like Linux or Windows they can affect your timing possibly. Many other things can and will. Pretty sure what you are supposed to is this:

1. Code the detection of the button press and the wait loop.

2. Look in your reference manual at the instructions you use and add up the clock cycles for all the instructions you use.

3. Take the clock speed of the processor and determine the period of one clock cycle and multiply the number of cycles your assembly language code takes to execute. Multiply the number of cycles your program uses by the period of one clock cycle.

It is admittedly kind of a dumb assignment. In the "real world" nobody does precise timing in this manner.
Programming homework and newbie help thread Quote
10-29-2015 , 11:10 AM
Well this is on an microcontroller so there is no OS. I don't need precise timing, if its off by milliseconds I don't care. I just need to be able to read the correct register so that I know a button was pressed, I just can't find what register to read
Programming homework and newbie help thread Quote
10-29-2015 , 11:59 AM
Quote:
Originally Posted by Alobar
Well this is on an microcontroller so there is no OS. I don't need precise timing, if its off by milliseconds I don't care. I just need to be able to read the correct register so that I know a button was pressed, I just can't find what register to read
Well how is the button interfaced to the micro controller? I would guess on some digital input. If it is how do you address digital inputs? Post the microcontrollers you are using including specific model numbers and we'll take it from there.
Programming homework and newbie help thread Quote
10-29-2015 , 12:20 PM
Quote:
Originally Posted by adios
Well how is the button interfaced to the micro controller? I would guess on some digital input. If it is how do you address digital inputs? Post the microcontrollers you are using including specific model numbers and we'll take it from there.
Its a PIC32MX795F512L

all the documentation is here

http://www.microchip.com/wwwproducts...#documentation

this part deals specifically with the I/O and registers

http://ww1.microchip.com/downloads/e...Doc/61120D.pdf

and this talks about input capture

http://ww1.microchip.com/downloads/e...Doc/61122F.pdf

The button is read through on pin 4 of the board which is here

http://www.digilentinc.com/Data/Prod...T_Max32_RM.pdf (page 11).


I've spent a good number of hours now reading all this stuff and I'm still hugely confused, so I appreciate any help!
Programming homework and newbie help thread Quote
10-29-2015 , 01:43 PM
Quote:
Originally Posted by econophile
Speaking of abstract vs. concrete, I strongly recommend Code: The Hidden Language of Computer Hardware and Software by Charles Petzold.

It starts off simple with switches and explains how switches can be combined into relays (essentially mechanical versions of transitors); how relays can be combined into logic gates (AND, OR, XOR, etc.); how logic gates can be combined into circuits that can add, subtract, multiply and divide (ALUs) and circuits that store information (RAM); and how these components can be combined into a simple computer with switches for inputs and light bulbs for outputs. Along the way, he also touches on Morse code, Braille, barcodes, machine language, 86x assembly language, high level languages, ASCII, simple operating systems, and computer graphics, all within 400 pages.

It's simply one of the best books on any subject that I have read in a while. And for me it was really helpful to start from the bottom and build up each layer of complexity. Modern computers so often just seem to work like magic, so it can be a little mind-blowing to see how everything they do results from incredibly simple operations being performed over and over again according to specific patterns and at incredible speeds.

This may have been easier to grasp with older computers when you typed a command and then had time to think about what was going on inside the computer while it calculated the output. I remember my dad showing me how to write a simple BASIC program on his monochrome luggable IBM-compatible in the mid 80s. Those machines seem much simpler than the ones we use today, although they are still exceedingly complicated.

At any rate, gaining some understanding of how the complex behavior of computers emerges from layer upon layer of simple rules and instructions makes it easier to think about how the same thing can happen with neurons. (I also think it was helpful to read this book before trying to learn C.)
This looks really interesting. Have you tried out NAND to Tetris yet? I've been meaning to get to that one for years.
Programming homework and newbie help thread Quote

      
m