1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Zina [86]
3 years ago
9

What are the major differences between searching and sorting in Java? What are some of the differences in the techniques used in

selection sorting and merge sorting? How is the performance of a sorting algorithm determined in regard to Big-Oh notation? In what instances can searching and sorting algorithms be used? Provide specific examples of each. Do not post examples previously posted by your peers in this discussion forum.
Computers and Technology
1 answer:
Studentka2010 [4]3 years ago
5 0

Answer:  

  • Searching is a technique to look for an item or target value in a data structure like searching for a phone number in a directory.Data structure can be an array,List etc. Searching algorithms are used for searching. Most common examples are Linear Search and Binary Search. Lets take the example Linear Search in order to explain it using JAVA. Its the simplest searching algorithm. To search for a specific element, look at each element in the data structure sequentially and check if it matches with the element being searched for.
  • Sorting is a technique of arranging the elements in a specific order e.g. numerical sorting, ordering students according to their exam score. This order can be ascending or descending or alphabetical order. Contrary to search it returns the data structure e.g. an array in which the elements of array are sorted in a particular order. Sorting algorithms are used to sort elements in a data structure. Some common examples of sorting algorithms are Bubble Sort, Insertion Sort, Selection Sort, Merge Sort, Quick Sort, Heap Sort etc. JAVA uses Array.Sort() built-in function for sorting an array. By default it sorts the input array in ascending order.
  • Selection Sort: It is a sorting technique which divides an array into two subarrays. One subarray in the left is sorted and the other one at right is unsorted. This is an in-place algorithm. It is not a good option for large data. Initially the sorted part is empty and all elements are placed in unsorted array. First the element which is the smallest in the unsorted array is selected and swapped with the leftmost array element and becomes part of the sorted array. In each iteration the smallest element from the unsorted array is selected and moved to sorted part of the array.The worst case time complexity of this algorithm is O(n)^2 as we have to find the smallest for every element in the array.
  • Merge Sort: It is a comparison based algorithm. It works on divide and conquer technique. It uses recursion approach for sorting. This means it breaks the problem(lets say array list to be sorted) into sub problems (smaller parts) and then solves (in this case sorts) each sub problem in a recursive manner. At the end it merges the solutions (hence the merged sorted array). Although selection sort works faster when data set is small merge sort outperforms it for larger data sets. Merge sort is a stable algorithm and works best for linked lists. Its not an in place algorithm. Time complexity of merge sort is O(n*log n) for best, average and worst cases because it always divides the array in two parts and takes linear time to merge these part. O(n(logn)) time complexity makes it better,more efficient and faster to sort large data sets.
  •  Big Oh O notation is an asymptotic annotation written as O(n) which is a mathematical way to represent the upper bound of the running time of   algorithm (sorting algorithm in this case). It computes the worst case time complexity. Worst case time complexity means that the longest amount of time or maximum number of operations that will be required for a sorting algorithm to complete. The time complexity mostly gets affected as the size of the input varies.
  • For example lets find out the worst-case time complexity of Bubble Sort for a list of n elements. Worst case is when the array is reversed sorted. At first iteration it would make n-1 comparisons. At iteration 1, for n-2 times and so total comparison will be O(n^)2. So the time to run program is proportional to the square of the input size.
  • Searching algorithms are used when there is a need to find a specific data item from bulk of data item. Searching algorithms make this hectic process easier. For example you want to find phone number of person from directory. without searching algorithm looking for each phone number in the directory manually can be very time consuming. For example you have to find address of a customer number 254 from database to deliver a product. Instead  of manually looking for customer numbers you can simply use  linear search algorithm that will start from customer 1 and sequentially searches for specific customer 254 number and provides the address in a shorter time.
  • Sorting reduces complexity of problems e.g reducing the searching complexity. It is easier to locate data elements in a sorted list than unsorted. For example comparing two large data sets containing millions of records. If both the data sets are ordered, the comparison gets easier. Moreover every sorting algorithm has certain usage. Like merge sort is useful for linked lists,heap sort is good with arrays and uses less memory. If data is small with large values, selections sort is better for this. It doesn’t require any additional space. Databases use merge sort to arrange data that is too large to be loaded completely into memory.  Heap sort is used in reading bar codes on plastic cards. Quick sort is used to maintain sports score on the basis of win-loss ratio.
You might be interested in
Many mobile computers and mobile devices use LCD monitors. What does LCD stand for?
erica [24]
Liquid crystal display
4 0
3 years ago
What makes the Columbus<br> Research Laboratory<br> different from Earth Labs?
Kitty [74]

Answer:

The Columbus laboratory is ESA’s largest single contribution to the International Space Station. It was also the first permanent European research facility in space.

Explanation: that is something I know i don’t know if it will help you with your answer

4 0
2 years ago
A Turing machine with stay put instead of left is similar to an ordinary Turing machine, but the transition function has the for
sasho [114]

Answer:

The class of language the machines recognise is Regular Language (See Explanation Below)

Explanation:

Given

Form δ : Q × Γ → Q × Γ × {R, S}

From the above transition form, it can be seen that the machine cannot read square symbols passed to it.

Regarding the square the machine is currently reading, there are multiple movement of S and it shouldn't be so because any number of the multiple movement can be simulated by exactly one movement of S.

As stated earlier that sequence of moves can be simulated by just one movement.

Let R = the movement

This means the machine can only use right move efficiently.

With this, we can say that the machine only read input string.

This is a characteristic of DFA (Deterministic Finite Automata).

With this, we can conclude that some DFAs will simulate the Turing machine and that they only read regular language.

5 0
3 years ago
A loop decision point for an algorithm consists of three features: an initial value, a set of actions to be performed, and a(n)
pychu [463]

Answer:

Option c is the correct answer for the above question.

Explanation:

A loop is used to repeat some lines in some specific times which depends on some conditions of the loop. If a person wants to print "welcome" on 5 times then he can do this by two ways one is writing a print statement 5 times and the other is states a loop that executes 5 times through condition. The loop is described or written by three necessary points which are:-

  1. The fist is to initialize the initial value which tells the compiler for the starting point of the loop.
  2. The second is to any action for that condition variable which takes the loop for the direction of ending points.
  3. The third is a condition that defines the ending point of the loop.

The above question also states about the loop in which first and second points are given then the third point is necessary to complete the sentence which is states in option c. Hence the option c is correct while the other is not because--

  • Option 'a' states about the class operator which is not the part of the loop.
  • Option b states about the documentation plan which is also not the part of the loop.

5 0
4 years ago
Would this make sense"I will strive in your school academically" on a tech school application
tekilochka [14]
Maybe right on why u think u will strive or how you will but i'm not sure
3 0
3 years ago
Other questions:
  • How do you do these questions? The first two questions could have multiple answers and the third is one answer only.
    7·1 answer
  • Certain medications can increase risk of obtaining a sunburn true or false
    12·1 answer
  • Which variable name is the best to hold the area of a rectangle?<br> 1A<br> area<br> AREA<br> a
    13·1 answer
  • Which best describes obliteration in a forged document?
    11·1 answer
  • Find the complete predicate in the sentence below.
    6·1 answer
  • Open punctuation means that no punctuation follows the salutation or complimentary close. *
    9·1 answer
  • Explain the four misconceptions about entrepreneurship.
    7·1 answer
  • What are non-examples of wage and salary?
    7·1 answer
  • What would be the greatest tool for emphasis? (video class)
    9·1 answer
  • Please help me to creat flow chart​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!