An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to algorithm design.
3
votes
0answers
91 views
Open a lock with the least number of moves
Consider a lock, made of a system of wheels. Each wheel has 26 letters of the alphabet, in order, and each wheel is initialized with 'a'. If you move one wheel up, the display for that wheel moves to ...
0
votes
1answer
3 views
Why is insertion sort Θ(n^2) in the average case?
Insertion sort has a runtime that is Ω(n) (when the input is sorted) and O(n2) (when the input is reverse sorted). On average, it runs in Θ(n2) time.
Why is this? Why isn't the average ...
1
vote
1answer
70 views
Build BST from Preorder
Like many newbies, my head blows up from recursion. I looked up a lot of answers/explanations on SO. but I am still unclear on the concept. (This is not homework, I am trying to relearn what I ...
61
votes
7answers
1k views
Is there a way to measure how sorted a list is?
It may sound like a silly question, but I'd like to know if there is a way to measure how sorted a list is.
I mean, it's not about knowing if a list is sorted or not (boolean) but something like a ...
2
votes
2answers
123 views
A better way of keeping track of cursor position in a text-field while auto-correcting?
I am working on a jQuery plugin for converting Latin characters to Japanese kana symbols (live example) in real-time (auto-correct) and it works correctly if I'm not typing too fast.. Which is a ...
0
votes
2answers
32 views
Graham scan c++ won't work
My code for the graham scan is not working, it is supposed to get the perimeter of the convex hull. It gets the input of n points, which can have decimals. The algorithm returns a value higher than ...
5
votes
4answers
851 views
Count number of different values in chosen (large) range in VBA?
How can I count the number of different values (numbers and strings mixed) in a chosen (large) range in VBA?
I think about this in this way:
1. Read in data into one dimensional array.
2. Sort ...
1
vote
1answer
37 views
How do I find neighbors in Dijkstra's algorithm?
How do I go about finding the neighbors of nodes? What makes a certain node a neighbor to another node? By the way I am writing the code in Lua
0
votes
1answer
16 views
Constraint Satisfaction with Uncertainty
I'm trying to solve a problem in which the satisfaction of constraints cannot always be verified. I can find lots of papers on flexible constraint satisfaction, but that's not quite what I want. ...
3
votes
2answers
58 views
Can 15 puzzle really be solved by backtracking?
Recently I was reading a book called "Programming Challenges". It is basically a book about algorithms. One of the chapters of the book is devoted to a backtracking technique and at the end of the ...
0
votes
5answers
89 views
Java - Randomly selecting from already defined Integers
I'm working on a project right now and I'm in a bit of a sticky situation.
I'm trying to generate eight consecutive random numbers but with a catch. The value between one and another must not exceed ...
0
votes
2answers
54 views
Error: java.util.NoSuchElementException - Scanner not behaving as desired
Scanner returning NoSuch Element Exception error. Could you explain why is this happening.
The Scanner now passes and runs fine but it didn't take the nextLine input from the second Scanner call. ...
3
votes
4answers
1k views
How to find the periodicity in data?
I have a dataset (an array) and i need to find the periodicity in it. How should i proceed..??Please help. Thanks a lot in advance. Some body said i can use FFT but i am not sure how will it give me ...
1
vote
1answer
16 views
Building a partial data downloader / caching mechanism
I'm trying to write a .NET/MS SQL application that will download daily weather data from a web service and I'd like to store/cache that data in the local DB.
The way it's going to be used is:
* the ...
1
vote
2answers
36 views
Whats the difference between NP and co-NP
I know their complete counterparts mean that
NP - complete is the hardest in the NP problems and co-NP-complete means the hardest in co-NP problems but whats the difference between the two? My ...