Backtracking paradigm: is it possible to do it without recursion? [closed] - iteration

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
Example: sudoku solving with backtracking
How do you backtrack without recursion - using loops? I only found solutions when you call backtrack() itself.

You can emulate the recursion with a stack.
Essentially, backtracking does a depth-first search in the tree of candidate solutions. For sudoku, this tree has fully filled grids at the leaves and partially filled grids at the nodes. The root is the provided grid. A grid node is a child of another one if it can be derived from it by filling a number. With this analogy between depth-first search and backtracking, you can easily implement backtracking either recursively or with a stack.
The stack could (conceptually) contain candidate grids. First, the provided (and partially filled) grid is pushed on the stack. Then inside a while loop (checking whether the stack is empty or not), the top grid is popped. One checks whether the grid is fully filled or not. If it is fully filled, the sudoku constraints are verified and the grid is returned it if they are satisfied. If the grid is not fully filled, then other candidate grids are generated from it (possibly none) which are all pushed on the stack. This summarizes the idea of the conversion, but of course as is it is not really efficient.

Related

Efficiently blocking invalid solutions [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
What's the best way to block invalid solutions in Optaplanner? I know you can provide a negative hard score with HardSoftScore, but it might still take a long time exploring invalid solutions before arriving at a valid one.
For example, if you're seeing how many packages will fit in a truck, if the sum size of all packages exceeds the capacity of the truck, you don't want to explore any solutions in that space at all.
I think this runs counter to the way Optaplanner is expected to work, in which you have a lot of bad solutions and slowly converge towards a good solution. Veto'ing solutions doesn't give Optaplanner any information on why that solution was vetoed, and also it's possible that a better solution can only be found after traversing though a vetoable solution.
Instead, consider whether your score constraints are causing a score trap. Instead of using a fixed -1 hard score for a vetoable solution, have a score that's proportional to how bad that solution is.
In my example, this means instead of marking overcapacity solutions as hard -1, I should instead penalize them proportional to how over capacity they are, using the matchWeigher form of penalize.

Which all reasons can cause index to go into unusable state in oracle [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
We are using oracle DB. In the "ALL_INDEXES" table for some of the indexes the status value is showing as "UNUSABLE". This we have observed when we move tables from compressed to uncompressed or vice versa. But we have not perform moving of the tables and still it showing for some of the indexes unusable. Can someone explain which all reasons are there.
We are not creating lists on SO, but let's say the question is "What may caused the index go unusable?". The idea is that anything that touches the table(partition) segment with a "bulk" ddl operation, invalidates the index.
For example, if you truncate a partition or drop it, the global index will be set unusable.
(Edit: Here we can count also sqlldr-ing with direct path as discussed here)
Another reason would be that someone set it unusable;

UICollectionViewController develop and design [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
i'm new in objective-c and in apple development.
i need a help in how i can develop and design layout like the picture in the below link:
http://www.appcoda.com/wp-content/uploads/2012/04/Xcode-Folder.jpg
the idea is that there is a major category of pictures where the users of ipad app will click on the major picture and the sub window will opened below to show the sub image under that category.
each row should shown more than one item in the main category because of that i need to use UICollectionViewController.
i found one sample but they using tableview with only one item per row and below is the link:
https://github.com/cloudorz/lakai
anyone can help please.
I agree with Gabriele that this question is perhaps a little too broad for SO. But nevertheless I'd like to offer some advice: try JWFolder on GitHub: https://github.com/jwilling/JWFolders
It's pretty good for what you're after. Basically it takes a screenshot of the collection view before splitting it in half and sliding the bottom half down to reveal another view controller's view.
Look at the code, it's pretty clever how he does it. Cudos to Jonathan Wiling for coming up with it.
Come back to SO to ask specific questions if you have difficulty implementing a collection view using JWFolder. Good luck!

Are there Ciphers that get smaller? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
This question does not appear to be about programming within the scope defined in the help center.
Improve this question
I'm playing around with text transformations - ciphers. From all that I have surveyed it seems that all of these algorithms either break even in terms of transformed message length, or get larger. Are there any known algorithms/text transformations that when applied to a message actually make the message smaller (not counting the key, of course)?
For instance, RSA, when you encode the message, makes the encrypted message quite a bit larger than the original. Is there any such thing as that only the message becomes smaller, instead of larger, after (encryption, transformation, etc whatever you want to call it)?
I'm not doing this as part of security, so whether or not it's hackable is not of any interest to me.
P.S. I've done a lot of research in this area already through search engines (google, wikipedia, etc) but I have found no results. I don't want to say that such a technique doesn't exist without at least posting the question publicly first.
Thanks!
Compression tries to make input smaller. Obviously lossless compression will not make every input smaller, since that's impossible.
You can encrypt the compressed input if you want that. In principle compression and encryption are orthogonal concepts, but in some situations the length of the compressed text can be used to attack the system.
At first I thought about language transformation. Some English phrases translate to a single Chinese symbol. That's not a rigorous, mathematical example, but I suppose it qualifies.
Alternatively, from a bit-wise perspective, it wouldn't be possible to cipher/encode 2 bits of information in 1 bit.

Do search engines take into considertaion ARIA roles (http://www.w3.org/TR/wai-aria/)? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
My company's web-site is all about online games, so accessibility is not high on our priority list. SEO best practices, however, are. Searching on the net we couldn't find any discussion of whether or not ARIA is such a best practice (which is a kind of answer already :-). I found this surprising because using ARIA roles seems like a natural thing to do - they contain a lot of SEO-relevant meta-data (overall page structure, what parts of the page are the "main" as opposed to "service" navigation area, what parts contain "actual" vs. "related" vs. "independent" content, etc.). What's more, given they effect the user interface (screen readers and so on) they would tend to be pretty accurate when they exist.
Does anyone have specific knowledge about whether any search engines actually use this data, if it exists in a page?
Search engines like Google are pretty smart no matter how badly you set up your page, SEO relevant meta data or not.
The main thing is to make sure your page is marked up properly, that it validates and that you don't employ any "black-hat" techniques that could cause search engines to black list your page.
As for ARIA, I'm not sure if it's really going to make much difference one way or another.