Question:
Computer Science Question(s) on Records and Arrays 10pts?
2013-05-02 14:10:26 UTC
i'm in a introduction to data structures and algorithms(using pesducode). It's a non programming class really, so I don't know C/C++ just some BASIC, but we are on the topic of arrays and records and my question(s).

1) With regards to computer architecture, how does a computer allocate arrays and records?

2) I can see how arrays would need to be sorted and searched but do records ever need sorted? Also how are they searched? What popular algorithms(easy to understand maybe) are used with searching/snorting records? I can see searching, but wouldn't a record technically already be sorted thus not need a sort algorithm? Or would have you snort record types at one point?

Again I'm just learning this stuff so please be gentle, I am no means an expert and I apologize for my ignorance.
Three answers:
James
2013-05-02 16:38:12 UTC
1) Arrays are generally stored in memory sequentially (assuming you are not referring to dynamically allocated arrays). For example, lets say the word size in memory is 32 bits and you are storing an array of doubles (doubles that are size 64 bits) with an array length of 10. With either a big endian or little endian system each entry of the array will take up two memory locations and the values will be stored sequentially in memory. A good example of allocating arrays can be found http://www.phpnerds.com/article/programming-in-php/7. It may help with your records questions to.



2) Records of many types very often need to be sorted and searched for. Imagine how long it would take you to find a person in a phone book if it were not sorted alphabetically. Depending on the type of record the sorting and searching algorithm used will be different, but either way you need some manner of comparing the values (a key can also can be used to track a value which is often used in hash tables (http://en.wikipedia.org/wiki/Hash_table). Searching and sorting for these records also depends on the data structure you decided to use to hold the data. Often you would try to sort the values as you get them, but this process can be costly depending on how you do it. Often when applicable you would want to sort the items as you get them, but there comes times when people or systems need to change how things are sorted for some reason or another. Like for example you have a system that stores records by Person's first name, and then you have to make it sort by Last name, or maybe phone number value, or person id.



Sorry if I did not cover this very well... I tried to keep it rather simple. I would highly suggest doing a brief overview of linked lists, trees, and hash tables for good examples.
?
2017-01-19 13:19:41 UTC
1
2017-01-06 15:58:24 UTC
the actually introduction of a language is complicated, and intensely heavy on computing gadget technological knowledge. you should desire a reliable information of language grammar (LL, LR, LALR, and so on.), how syntax should be processed (parsing tables and graphs etc). initially, an interpreted language is likely simplest to administration. they could both be compiled to interior of sight code, C and C++ courses paintings like this. they is often byte-compiled to a pseudo code that's then dealt with by utilizing yet another application. that's how Java and C# works. they is often interpreted like shell scripts. turning out to be a compiler or a byte-compiler is a complicated topic as well. you could look on different languages like C, Java, and open source compilers like gcc, and particular loose pascal compilers, and so on.. looking on compiler theory, language grammar theory will internet you extra resources. There should be college factor books on the placement once you've an activity in serious examining.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...