Tag Info

New answers tagged

0

Lots of trade offs and no one right answer. Many programmers would never consider using string keys in the database because they aren't aware of hashing and how a database works. String keys as long as they are either extremely stable, or meaningless (surrogates), are a good design choice in many circumstances.


0

I spent a lot of time hacking around in C/C++ with OpenGL. I know the languages and API well enough...and I've become a reasonable developer and programmer because of that experience. That said, the actual algorithmic knowledge required to solve various problems encountered I've only just really been able to grasp. Speaking from personal experience, ...


0

If you use double floating point numbers to indicate priority you do not need to re-order: 1.00 Task A 2.00 Task B 3.00 Task C 4.00 Task D 5.00 Task E If you want to place task E between A and B then:- E.priority = B.priority + ((B.priority - A.priority) / 2) So now you have: 1.00 Task A 1.50 Task E 2.00 Task B 3.00 Task C 4.00 Task D If you ...


0

Conceptually speaking, a stack is a linked list without random access and only one point of entry: the top, whereas a list often has random access and two points of entry: the front and the back. While there usually is a T peek(), peek can't be used for manipulation of the contents. Random access is usually explained as the ability to manipulate at any given ...


3

A stack can either be empty (which is really easy to write), or it can not be empty in which case it has a top item and a pointer to the rest of the stack. To implement a stack without using java library, create a class called Node, which contains a pointer reference to the next stack entry only. create a class called MyStack, which contains the last ...


6

Since you tag the question as java we solve the question with.....Objects! We're actually pretty much going to be implementing a singularly linked list. A stack can either be empty (which is really easy to write), or it can not be empty in which case it has a top item and a pointer to the rest of the stack. Below is code for an immutable stack (one in which ...


0

You dont have to use an array or a list, you can create a simple stack by doing the following: create a class called StackEntry, which contains a reference to the next stack entry only. create a class called MyStack, which contains the last stack entry, and two functions: push(value): creates a new stack entry. sets it to refer to the current stack ...


10

A stack is really just an interface, which provides at least the following operations: push a new element onto the stack pop an element off the stack The underlying implementation can be anything that satisfies these operations. Arrays and lists are common implementations for stacks, but you could create an (inefficient) stack using a hash table, or ...


1

Yes, PHP arrays are dynamic, in the sense that one can create an array, insert new elements, delete elements, etc. without ever worrying about its size. The array grows or shrinks as needed, automatically. You didn't quite fully "do your homework" though, since most PHP programming books would have told you the above :) By the way, if you need a ...


0

There are a whole range of reasons that might be true, but the key ones are likely to be: Hash tables are easier to implement than trees. Neither is entirely trivial, but hash tables are a bit easier, and the impact on the domain of legal keys is less stringent as you just need a hashing function and an equality function; trees require a total order ...


3

This is a general, non-Python-specific answer. Algorithmic complexity comparison | Hash Table | Red-Black Tree | |=============|=====================| Space | O(n) : O(n) | O(n) : O(n) | Insert | O(1) : O(n) | O(log n) : O(log n) | Fetch | O(1) : O(n) | O(log n) : O(log n) | Delete | O(1) : O(n) | O(log n) : O(log n) | ...


0

My understanding of adaptive Huffman coding is that its implementation requires a weighted tree, and then weights are being operated on, so a standard binary tree, or binary search tree, or a heap, cannot be used 'as is'. In fact, a BST doesn't seem very appropriate, whereas a heap might be a good start, given that (in Vitter's algorithm at least) nodes must ...


0

It really depends on the scale you have in mind. Sparse matrices will only take you that far... For Google and similar very large scale applications, think more along the line of distributed databases. Just to mention, there are indeed several papers available (via Google Scholar, say) that discuss Google's approach to distributed storage (BigTable), or ...


0

A Data Structure is a computer science term for some way of ordering data, and how you can store/retrieve data from it. A Collection is a Data Structure which can hold an arbitrary number of objects. There are many types of collections, differentiated by their data organization and by their store/retrieve algorithms, giving different complexity in different ...


9

A Data Structure is any structure that holds data. Data Structures are distinguished from each other by their memory usage and performance characteristics. For example, the lookup performance of a Hash Table is O(1), while that of a balanced binary tree is O(log n). A Collection is any data structure that can hold zero or more data items. Generally, ...



Top 50 recent answers are included