Application of merge sort [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Merge sort application
Can anyone tell me what does online sorting means?I could not find perfect answer.
Source : http://en.wikipedia.org/wiki/Merge_sort
Thanks in advance!

Quicksort gained widespread adoption, appearing, for example, in Unix as the default library sort function, whence it lent its name to the C standard library function qsort and in the reference implementation of Java.
Merge sort type algorithms allowed large data sets to be sorted on early computers that had small random access memories by modern standards. Records were stored on magnetic tape and processed on banks of magnetic tape drives . merge sort is implemented with disk drives.
For more read : http://en.wikipedia.org/wiki/Merge_sort
http://en.wikipedia.org/wiki/Quicksort#References

Their applications vary; it depends on the size and contents of what you're sorting.
Quicksort is one of the fastest sorting algorithms, so it is commonly used in commercial applications.
Merge sort is used mostly under size constraints because it isn't as hefty an algorithm as Quicksort.

Both algorithms can be used in distributed systems for sorting data.
Merge sort is a typical example used in online sorting.
On the other hand quick sort also has some usage in graphic/game development where u need to sort data points and cluster them out.

Related

When does an algorithm become considered artificial intelligence? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I understand that an algorithm is a set of instructions. Ai is essentially the same thing, only, more complicated? Let's say I use a minmax algorithm to allow moves to be played on a tic tac toe board, generally people would consider this ai. But if I implement an algorithm to solve a rubiks cube, is that considered ai?
I guess what I'm asking is, is it the complexity of the algorithm, the fact that situations change on the fly in an algorithm, the ignorance of the user/programmer as to how the algorithm works or all/some of the above? Or am I missing something?
I feel like this field is quite arbitrary. I imagine for good reason.I imagine because complexity is complex.
It is indeed quite arbitrary.
If you consult wikipedia you might find following definition which in my personal opinion catches the load quite accurately:
Computer science defines AI research as the study of "intelligent
agents": any device that perceives its environment and takes actions
that maximize its chance of successfully achieving its goals. A more
elaborate definition characterizes AI as "a system's ability to
correctly interpret external data, to learn from such data, and to use
those learnings to achieve specific goals and tasks through flexible
adaptation."
To take your Rubiks Cube as an example, there would be at least 2 ways you could write the algoritm to solve the puzzle. Firstly, any cube can be solved by following a hardcoded path or set of instructions once you have a certain start position. Implementing this would not be considered AI in my opinion as the machine itself is not learning anything. It just follows a well defined path of instructions till the end.
A second way to implement this would be to have the program just start solving it randomly. But the machine remembers it's moves, and learns the most effective path to reach the solution. When solving the next cube, the machine can build upon this newly learned information to solve it faster and again learn from this iteration to improve it's algorithm.
So in short, as far as I'm concerned, it can be considered AI when a machine is capable of optimizing/extending its own algorithms to become more efficient in its tasks.

graph traversal in C [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have to implement a backtracing algorithm in C which will emulate a hardware in purely software, and trace a single path from output of a system to the input pin, registering all the gates, their outputs and inputs(taken) on the path in a reverse order. I figured out that it can be done in graph traversal algorithm but not able to implement in C. Any useful suggestions shall be helpful indeed!
I've done a few maze solving algorithms, both breadth and depth first search.
I'd say you should first build a graph and make sure its perfectly built and without any incoherence, and something i found to be very useful was to find a way to print my graph to check for errors :).
Other than that, good luck !
Depends on what kind of path tracing, it can follow both breadth first search or else Depth first search. I have tried both of them and it works.

Writting a syntax analyser using an AFD for C language [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have been given a task to write a C language analyser using an AFD. I can choose whichever language I want so I think I will go for Ruby. However this task is a little overwhelming to grasp at the beginning.
The problem I stumble across is : How do I even represent the AFD of the entire C language?.
I have been doing a little bit of digging and I ended up reading this on lexical analysis. In this paper the author defines every token of the language as a transition between 2 states (which is very logical). I find it almost impossible for me not to miss a few or build such a big AFD by hand without many mistakes. Any tips ?
The task you have is a similar one posed to many undergraduate students in compiler courses every year in thousands of universities, and the notes you cite are good sample of the many sets of course notes available on the topic.
The solution is the same as any software engineering problem: testing against the specification.
Although the intellectual problem of the analysis and creation of AFDs for a whole language by hand might seem overwhelming error prone, don't forget you are tasked with also implementing this (in your chosen language of Ruby).
This implementation can be tested by feeding it carefully graded and selected samples of C language input. When it does not deliver the expected result there error will either be in the coding of the AFD or a fault in the AFD you constructed. You make the necessary change and go around the testing loop again.
You will eventually end up with a valid AFD for the entire C language and an analyser for it written in Ruby.
It is often a good idea to start small and implement a subset of the C language and get that working first and then add more to it using stepwise refinement. This is a less risky strategy than attempting to do the whole thing in one go.
You need to apply all those techniques you should have learned about building specifications, designs, programs and testing and apply it to this problem. Just apply good computer science and software engineering to this problem.

How to write the Sorting on a Singly Linked List in C [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a question. I hope everybody help me.
I'm learning Data Structures in C. I have a homework but I can't find a solution to solve it.My teacher wants me write 11 sorts.
In singly linked list i has installed 6 sorts:Interchange Sort, Bubble Sort, Selection Sort, Quick Sort, Merge Sort and Radix Sort.
So i need everybody help me write 5 sorts: Insertion Sort, Binary Insertion Sort, Shaker Sort, Heap Sort, Shell Sort. If it can't use in singly linked list,can you tell me why it can't use?
I really need your help. Please answer to help me.Thank you very very very much!!!!!
http://en.wikipedia.org/wiki/Sorting_algorithm
This will give you various sorting algorithms, and when you select most of the algorithms wikipedia will have some pseudo code for that algorithm. It's a really good exercise to translate pseudo code into the native language that you're writing it in (in this case C); I still do it when I'm learning a new language since implementing sorting algorithms usually gives you a good handle on the basics of that language.
From a more mothering/lecturing point, you won't have an easier time in your later classes if all you end up doing is getting your code from other people, you need to solve it yourself, plain and simple.
From the list of one's you have done quick and merge sort are probably the hardest, if you have those written (and actually wrote them) the rest should be fairly easy.

Good references for algorithm efficiency [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I want to fundamentally learn algorithm efficiency by self study (hopefully both in how a program can make best use of hardware and in designing an algorithm). I wanted to know about some good books on this topic. I write my programs in c.
I'll recommend the book Algorithms in C, Parts 1-4: Fundamentals, Data Structures, Sorting, Searching, the author Robert Sedgewick has a magic power to explain hard things easily understood. The book though not well edited, is the best reference on data structure and algorithms in C I've read.
Quoting from editorial reviews:
Highlights
Expanded coverage of arrays, linked lists, strings, trees, and other
basic data structures Greater emphasis on abstract data types (ADTs)
than in previous editions
Over 100 algorithms for sorting, selection, priority queue ADT
implementations, and symbol table ADT (searching) implementations
New implementations of binomial queues, multiway radix sorting,
Batcher's sorting networks, randomized BSTs, splay trees, skip lists,
multiway tries, and much more
Increased quantitative information about the algorithms, including
extensive empirical studies and basic analytic studies, giving you a
basis for comparing them
Over 1000 new exercises to help you learn the properties of
algorithms
Whether you are a student learning the algorithms for the first time or a professional interested in having up-to-date reference material, you will find a wealth of useful information in this book.
As a reader, I'll say it deserves this accomplishment.

Resources